我的ansible剧本中有以下任务:
- name: Install EPEL repo.
yum:
name: "{{ epel_repo_url }}"
state: present
register: result
until: '"failed" not in result'
retries: 5
delay: 10
我可以传递给状态的另一个值是“已安装”。两者有什么区别?此处提供了一些文档:http : //docs.ansible.com/ansible/yum_module.html
它们做同样的事情,它们是彼此的别名,请参见yum模块的源代码中的以下注释:
# removed==absent, installed==present, these are accepted as aliases
以及它们在代码中的用法:
if state in ['installed', 'present']:
if disable_gpg_check:
yum_basecmd.append('--nogpgcheck')
res = install(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
elif state in ['removed', 'absent']:
res = remove(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
elif state == 'latest':
if disable_gpg_check:
yum_basecmd.append('--nogpgcheck')
res = latest(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
else:
# should be caught by AnsibleModule argument_spec
module.fail_json(msg="we should never get here unless this all"
" failed", changed=False, results='', errors='unexpected state')
return res
https://github.com/ansible/ansible-modules-core/blob/devel/packaging/os/yum.py
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句