ansibleのyumモジュールpresentとinstalledの違い

1056 ワード

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
    

    どちらも選択リストに表示されます.