Last active
January 7, 2020 13:46
-
-
Save bpelaia/2a41982c4aebb471afc3af74fcc65fc0 to your computer and use it in GitHub Desktop.
docker and tz ansible playbook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo mkdir /etc/ansible | |
$ sudo chown root:adm /etc/ansible | |
$ sudo chmod 770 /etc/ansible | |
$ cat > /etc/ansible/hosts <<EOF | |
all: | |
children: | |
localCentosVm: | |
hosts: | |
192.168.56.111: | |
192.168.56.112: | |
oracleCloud: | |
hosts: | |
instance-abc.oracle.cloud.domain.com: | |
second.oracle.cloud.domain.com: | |
ubuntu: | |
hosts: | |
instance-abc.oracle.cloud.domain.com: | |
second.oracle.cloud.domain.com: | |
vars: | |
ansible_user: ubuntu | |
ansible_become: true | |
ansible_become_user: root | |
ansible_become_method: sudo | |
centos: | |
hosts: | |
192.168.56.111: | |
192.168.56.112: | |
vars: | |
ansible_user: root | |
ansible_become: false | |
EOF | |
$ ansible-inventory --list | |
[...] | |
$ eval `ssh-agent -s` | |
$ ssh-agent | |
### INPUT KEY PASSPHRASE ### | |
$ ansible all -m ping | |
192.168.56.111 | SUCCESS => { | |
"ansible_facts": { | |
"discovered_interpreter_python": "/usr/bin/python" | |
}, | |
"changed": false, | |
"ping": "pong" | |
} | |
192.168.56.112 | SUCCESS => { | |
"ansible_facts": { | |
"discovered_interpreter_python": "/usr/bin/python" | |
}, | |
"changed": false, | |
"ping": "pong" | |
} | |
[...] | |
$ mkdir roles | |
$ cd roles | |
$ git clone https://github.com/geerlingguy/ansible-role-docker.git geerlingguy.docker | |
$ cd .. | |
$ cat >docker-playbook.yml <<EOF | |
--- | |
- hosts: all | |
pre_tasks: | |
- name: Update apt cache. | |
apt: update_cache=yes cache_valid_time=600 | |
when: ansible_os_family == 'Debian' | |
roles: | |
- role: geerlingguy.docker | |
EOF | |
$ ansible-playbook --syntax-check docker-playbook.yml | |
[...] | |
$ ansible-playbook -C docker-playbook.yml | |
[...] | |
$ ansible-playbook docker-playbook.yml | |
[...] | |
$ cat >rome_timezone-playbook.yml <<EOF | |
--- | |
- name: Set Europe/Rome TimeZone | |
hosts: all | |
tasks: | |
- name: Set timezone to Europe/Rome | |
timezone: | |
name: Europe/Rome | |
EOF | |
$ ansible-playbook rome_timezone-playbook.yml | |
[...] | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment