Skip to content

Instantly share code, notes, and snippets.

@edsoncelio
Last active May 17, 2019 17:17
Show Gist options
  • Save edsoncelio/3c6937d88ff3c249b9fb0873b26eca03 to your computer and use it in GitHub Desktop.
Save edsoncelio/3c6937d88ff3c249b9fb0873b26eca03 to your computer and use it in GitHub Desktop.
Dicas e comandos úteis - Ansible

Verificar erros de sintaxe

ansible-playbook playbooks/PLAYBOOK_NAME.yml --syntax-check

Executar o ansible no modo dry-run

ansible-playbook playbooks/PLAYBOOK_NAME.yml --check

Caso os módulos não funcionem, usar o modo raw:

ansible -m raw -s -a "yum install libselinux-python -y" new-atmo-images

Limitar a execução do playbook por hosts:

  • ansible-playbook playbooks/PLAYBOOK_NAME.yml --limit "host1"
  • ansible-playbook playbooks/PLAYBOOK_NAME.yml --limit "host1,host2"

Limitar tasks por tags:

ansible-playbook playbooks/PLAYBOOK_NAME.yml --tags 'install'

Pular tasks por tags:

ansible-playbook playbooks/PLAYBOOK_NAME.yml --skip-tags 'sudoers'

Nomear os hosts no inventário:

[web]
host1 ansible_host=127.0.0.1
host2 ansible_host=192.1678.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment