美文网首页
ansible的yum模块present和installed区别

ansible的yum模块present和installed区别

作者: andymilion | 来源:发表于2018-06-05 09:42 被阅读0次

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

    • absent
    • installed
    • latest
    • present
    • removed

    比较疑惑的是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
    

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

    相关文章

      网友评论

          本文标题:ansible的yum模块present和installed区别

          本文链接:https://www.haomeiwen.com/subject/offpsftx.html