Ansible 작업이 옵션 문제를 생성합니다.

Ansible 작업이 옵션 문제를 생성합니다.

특정 패키지가 없는 경우에만 패키지를 설치하기 위해 Ansible 플레이북을 작성하고 싶습니다. 따라서 /tmp/hosted파일이 있는 경우 설치가 진행되어서는 안 되지만 실패합니다.

---
 - hosts: all
   sudo: yes
   tasks:
   - name: Ensure NTP (for time synchronization) is installed.
     yum:  name=ntp state=present
     args:
      creates: "/tmp/hosted"

오류:

[root@ns0 ansible]# ansible-playbook creates.yml -l ansi2
[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default).
This feature will be removed in
 a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [all] ***********************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************
ok: [ansi2]

TASK [Ensure NTP (for time synchronization) is installed.] ***********************************************************************************************
fatal: [ansi2]: FAILED! => {"changed": false, "failed": true, "msg": "Unsupported parameters for (yum) module: creates. Supported parameters include: conf_file,disable_gpg_check,disablerepo,enablerepo,exclude,install_repoquery,installroot,list,name,skip_broken,state,update_cache,validate_certs"}
        to retry, use: --limit @/etc/ansible/creates.retry

PLAY RECAP ***********************************************************************************************************************************************
ansi2                      : ok=1    changed=0    unreachable=0    failed=1

답변1

이것은 작동합니다

---
- hosts: all
  become: yes
  tasks:
    - name: Check existence of /tmp/hosted
      shell: test -e /tmp/hosted
      register: hostedfile
      ignore_errors: yes

    - name: Ensure NTP (for time synchronization) is installed.
      yum:  name=ntp state=present
      when: hostedfile.rc != 0

관련 정보