https://github.com/devenes/ansible-notes
Ansible Command Documentation
https://github.com/devenes/ansible-notes
ansible playbook
Last synced: 7 months ago
JSON representation
Ansible Command Documentation
- Host: GitHub
- URL: https://github.com/devenes/ansible-notes
- Owner: devenes
- Created: 2022-05-18T19:45:47.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-05-21T21:50:56.000Z (over 3 years ago)
- Last Synced: 2025-01-03T15:44:24.981Z (about 1 year ago)
- Topics: ansible, playbook
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ansible Command Documentation
```bash
ansible-doc ping
```
```yml
ansible --help
ansible-playbook --help
```
```bash
ansible --list-host all
ansible --list-host dev
ansible --list-host webservers
ansible --list-host \!webservers
ansible --list-host webserver:devservers
```
## playbook info
```bash
# check mode
ansible-playbook playbook.yml --check
ansible-playbook playbook.yml --check --diff
```
```bash
# debugging
ansible-playbook playbook.yml -vvv
```
```bash
# limit selected host
ansible-playbook playbook.yml -l node1
```
```bash
# list host in playbook
ansible-playbook playbook.yml --list-hosts
```
```bash
# list tasks in playbook
ansible-playbook playbook.yml --list-tasks
```
## list inventory
```bash
ansible-inventory --list
ansible-inventory --graph
```
## list inventory plugins
```bash
ansible-doc -t inventory -l
# aws_ec2 plugin doc
ansible-doc -t inventory aws_ec2
# list dynamic inventory in yaml
ansible-inventory -i inventory_aws_ec2.yml --list --yaml
```
## list ansible facts
```bash
ansible all -m setup
ansible all -m gather_facts
ansible node3 -m setup | grep ansible_distribution_version
ansible node1:node2 -m setup | grep ansible_os_family
```
## Display facts from all hosts and store them indexed by I(hostname) at C(/tmp/facts)
```bash
ansible all -m setup --tree /tmp/facts
```
## Ansible Configuration Settings
```bash
ansible-config dump
ansible-config dump | grep ROLE
ansible-config list | grep -E 'HOST_KEY|true'
```
```bash
# view your "ansible.cfg" file
ansible-config view
```
## run multiple playbooks in one playbook
```yml
# playbooks.yml
- import_playbook: ping.yml
- import_playbook: shell.yml
- import_playbook: configure.yml
```