https://github.com/pgaref/ansible_collection
A repository with a number of ansible playbooks and roles that made my daily cluster management tasks easier!
https://github.com/pgaref/ansible_collection
Last synced: 8 months ago
JSON representation
A repository with a number of ansible playbooks and roles that made my daily cluster management tasks easier!
- Host: GitHub
- URL: https://github.com/pgaref/ansible_collection
- Owner: pgaref
- Created: 2016-05-21T20:58:47.000Z (about 10 years ago)
- Default Branch: public
- Last Pushed: 2016-05-23T19:42:08.000Z (about 10 years ago)
- Last Synced: 2025-01-08T06:35:45.517Z (over 1 year ago)
- Language: Shell
- Size: 449 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-Tutorial/inventory.md
Awesome Lists containing this project
README
Ansible tutorial
================
# Inventory
Before continuing, you need an inventory file. The default place for such a
file is `/etc/ansible/hosts`. However, you can configure ansible to look
somewhere else, use an environment variable (`ANSIBLE_HOSTS`), or use the `-i`
flag in ansible commands an provide the inventory path.
We've created an inventory file for you in the directory that looks like this:
```bash
host0.example.org ansible_host=192.168.33.10 ansible_user=root
host1.example.org ansible_host=192.168.33.11 ansible_user=root
host2.example.org ansible_host=192.168.33.12 ansible_user=root
```
`ansible_host` is a special _variable_ that sets the IP ansible will use
when trying to connect to this host. It's not necessary here if you use the
vagrant-hostmaster gem. Also, you'll have to change the IPs if you have set
up your own virtual machines with different addresses.
`ansible_user` is another special _variable_ that tells ansible to
connect as this user when using ssh. By default ansible would use your
current username, or use another default provided in ~/.ansible.cfg
(`remote_user`).
# Testing
Now that ansible is installed, let's check everything works properly.
```bash
ansible -m ping all -i step-01/hosts
```
What ansible will try to do here is just executing the `ping` module (more on
modules later) on each host.
The output should look like this:
```json
host0.example.org | success >> {
"changed": false,
"ping": "pong"
}
host1.example.org | success >> {
"changed": false,
"ping": "pong"
}
host2.example.org | success >> {
"changed": false,
"ping": "pong"
}
```
Good! All 3 hosts are alive and kicking, and ansible can talk to them.