2017-06-16 1 views
0

Nach dem Ausführen der die folgenden ansible YAML-Datei zeigt die Ausgabe-Datei erstellt wird und der Inhalt geändert wirdansible Erstellung der Datei nicht ohne Fehler

Die YAML Datei

--- 
- hosts: all 
    gather_facts: yes 
    connection: local 
    tasks: 
    - name: Check the date on the server. 
     action: command touch /opt/b 
    - name: cat the Content 
     action: command cat /opt/b 

Ausführen des Textbuch

[email protected]:/var/lib/awx/projects/test# ansible-playbook main.yml 

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

TASK [setup] ******************************************************************* 
ok: [ansible-ubuntu-1604-db] 

TASK [Check the date on the server.] ******************************************* 
changed: [ansible-ubuntu-1604-db] 
[WARNING]: Consider using file module with state=touch rather than running touch 


TASK [cat the Content] ********************************************************* 
changed: [ansible-ubuntu-1604-db] 

PLAY RECAP ********************************************************************* 
ansible-ubuntu-1604-db  : ok=3 changed=2 unreachable=0 failed=0 

Das Meldungsdisplay c = 2 und Aufgaben hängen müssen nicht jede Datei erstellt

[email protected]:~$ ls -l /opt/ 
total 0 

Die Env

  1. ansible-Controller auf dem MAC lokalen Desktop
  2. Tagte Knoten ist auf Wolke

Antwort

1

Mit connection: local In Ihrem Playbook geben Sie Ansible an, alle Aufgaben auf Ihrem lokalen ansible Controller auszuführen. So wird die Datei auf Ihrem lokalen Rechner erstellt.

Entfernen Sie connection: local und versuchen Sie es erneut.