https://github.com/spirosoik/mastering-ansible
Ansible usage to demonstrate ansible
https://github.com/spirosoik/mastering-ansible
ansible docker
Last synced: about 2 months ago
JSON representation
Ansible usage to demonstrate ansible
- Host: GitHub
- URL: https://github.com/spirosoik/mastering-ansible
- Owner: spirosoik
- Created: 2017-10-18T06:32:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-17T21:31:54.000Z (over 8 years ago)
- Last Synced: 2025-06-20T10:08:40.681Z (about 1 year ago)
- Topics: ansible, docker
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Simple Commands
```
# see all hosts
ansible --list-hosts all
# see hosts by Inventory
ansible -i dev --list-hosts all
# create ansible.cfg and define the [defaults] for Inventory
# to avoid the `-i dev`
ansible --list-hosts all
or
ansible --list-hosts "*"
# see all hosts for inventory group
ansible --list-hosts
eg.
ansible --list-hosts loadbalancer
ansible --list-hosts db01
ansible --list-hosts "app0*"
ansible --list-hosts database:control
ansible --list-hosts webserver[0]
ansible --list-hosts \!control
# ping module
ansible -m ping all
# command module, which is also the default
ansible -m command -a "hostname" all
```
## Playbooks execution
```
ansible-playbook loadbalancer.yml
```
## Roles
Create a scaffolding structure for your roles.
```
ansible-galaxy init control
```
## Facts
Collect the facts for a host
```
ansible -m setup
```
## Vault
```
ansible-vault create vault
```
## Limit app to run
```
ansible-playbook site.yml --limit app01
```
## List/Run/Skip tags
```
ansible-playbook site.yml --list-tags
```
Run by tag:
```
ansible-playbook site.yml --tags "packages"
```
Run and skip specific tags
```
ansible-playbook site.yml --skip-tags "packages"
```
## Run by step
```
ansible-playbook site.yml --step
ansible-playbook site.yml --list-task # find all tasks
ansible-playbook site.yml --start-at-task "name of the task" # starts running from given task name
```
# Syntax Checks
```
ansible-playbook --syntax-check site.yml
ansible-playbook --check site.yml # execution dry run
```