ansible的yum模块present和installed区别

2018-06-05  本文已影响0人  andymilion

在使用ansible yum模块时,state选项有如下几种:

比较疑惑的是present 和installed,absent和removed的区别,其实他们含义是一样的,源码:

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

可以清楚的看到两者都在选择列表中。

上一篇 下一篇

猜你喜欢

热点阅读