kev*_*vmo 17 centos yum ansible epel
我的ansible剧本中有以下任务:
- name: Install EPEL repo.
yum:
name: "{{ epel_repo_url }}"
state: present
register: result
until: '"failed" not in result'
retries: 5
delay: 10
Run Code Online (Sandbox Code Playgroud)
我可以传递给州的另一个值是"已安装".两者有什么区别?这里提供了一些文档:http://docs.ansible.com/ansible/yum_module.html
Zle*_*ni 14
他们做同样的事情,他们是彼此的别名,在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
Run Code Online (Sandbox Code Playgroud)
https://github.com/ansible/ansible-modules-core/blob/devel/packaging/os/yum.py
| 归档时间: |
|
| 查看次数: |
14172 次 |
| 最近记录: |