Bonjour à toutes et à tous,
Je me suis permis de m'inscrire sur ce forum par désepoir de cause. Après tant de recherche sur Google -certaines m'ayant fait découvrir ce forum-, je n'arrive toujours pas à comprendre comment gérer un inventaire Ansible. Je suis complètement dans le flou. J'espère que quelqu'un pourra éventuellement éclairer ma lanterne.
J'ai une structure ainsi:
.
├── inventories
│ ├── development
│ │ ├── group_vars
│ │ │ └── all.yml
│ │ └── hosts
│ └── test
│ ├── group_vars
│ │ └── all.yml
│ │ └── hosts
├── roles
└── test.yml
Dans les deux fichiers all.yml, je n'ai qu'une seule et unique variale. Voici le contenu complet du fichier:
1 2
| vars:
name:"development" |
Mon fichier test.yml contient ceci:
1 2 3 4 5 6 7 8
| - name: test playbook
hosts: localhost
connection: local
tasks:
- name:
debug:
var: name |
Je lance mon playbook ainsi:
ansible-playbook -i inventories/development/ test.yml -vvv
Et voici le résultat:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| $ ansible-playbook -i inventories/development test.yml -vvv
ansible-playbook 2.10.3
config file = None
configured module search path = [u'/home/amsou/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.18 (default, Aug 27 2020, 21:22:52) [GCC 7.3.1 20180712 (Red Hat 7.3.1-9)]
No config file found; using defaults
host_list declined parsing /home/amsou/AwsPlaybooks/tests/inventories/development/hosts as it did not pass its verify_file() method
script declined parsing /home/amsou/AwsPlaybooks/tests/inventories/development/hosts as it did not pass its verify_file() method
auto declined parsing /home/amsou/AwsPlaybooks/tests/inventories/development/hosts as it did not pass its verify_file() method
Parsed /home/amsou/AwsPlaybooks/tests/inventories/development/hosts inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: test.yml **************************************************************************************************************************************************************************
1 plays in test.yml
PLAY [test playbook] ************************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************
task path: /home/amsou/AwsPlaybooks/tests/test.yml:1
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: s4dad\amsou
<127.0.0.1> EXEC /bin/sh -c 'echo '"'"'~s4dad\amsou'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~s4dad\amsou/.ansible/tmp `"&& mkdir "` echo ~s4dad\amsou/.ansible/tmp/ansible-tmp-1606557383.4-20815-227899452309047 `" && echo ansible-tmp-1606557383.4-20815-227899452309047="` echo ~s4dad\amsou/.ansible/tmp/ansible-tmp-1606557383.4-20815-227899452309047 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/setup.py
<127.0.0.1> PUT /home/amsou/.ansible/tmp/ansible-local-20809uVZ_XA/tmpv07mj7 TO /home/amsou/AwsPlaybooks/tests/~s4dadamsou/.ansible/tmp/ansible-tmp-1606557383.4-20815-227899452309047/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x '"'"'~s4dadamsou/.ansible/tmp/ansible-tmp-1606557383.4-20815-227899452309047/'"'"' '"'"'~s4dadamsou/.ansible/tmp/ansible-tmp-1606557383.4-20815-227899452309047/AnsiballZ_setup.py'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 '"'"'~s4dadamsou/.ansible/tmp/ansible-tmp-1606557383.4-20815-227899452309047/AnsiballZ_setup.py'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r '"'"'~s4dadamsou/.ansible/tmp/ansible-tmp-1606557383.4-20815-227899452309047/'"'"' > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers
TASK [debug] ********************************************************************************************************************************************************************************
task path: /home/amsou/AwsPlaybooks/tests/test.yml:6
ok: [localhost] => {
"name": "VARIABLE IS NOT DEFINED!: 'name' is undefined"
}
META: ran handlers
META: ran handlers
PLAY RECAP **********************************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Est-ce quelqu'un pourrait illuminer ma lanterne? Je suis un peu perdu. Est-ce que j'ai toujours besoin d'un fichier ansible.cfg dans mon dossier ou j'ai mon playbook?
Merci d'avance pour toute réponses pouvant me guider
Partager