Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Last active December 17, 2020 08:19
Show Gist options
  • Save zeitounator/2dbbaedeaed8a01bdddeb641891020b1 to your computer and use it in GitHub Desktop.
Save zeitounator/2dbbaedeaed8a01bdddeb641891020b1 to your computer and use it in GitHub Desktop.
---
all:
vars:
ansible_connection: docker
hosts:
ans_centos7:
ans_centos8:
---
- hosts: all
tasks:
- debug:
var: ansible_python.version
- debug:
var: ansible_pkg_mgr
- package:
name: wget
$ docker run -d --rm --name ans_centos7 centos:7 tail -f /dev/null
8cc84f6c883d502597d3d51500835aafdf802244e919e209b24781b2506bc7d1
$ docker run -d --rm --name ans_centos8 centos:8 tail -f /dev/null
3ed7645cd053502fc978d2ae638ba85594eea1580b6e2345f60b1d1843ce32f3
$ ansible-playbook -i hosts.yml playbool.yml
PLAY [all] ****************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************
ok: [ans_centos8]
ok: [ans_centos7]
TASK [debug] **************************************************************************************************************************************
ok: [ans_centos7] => {
"ansible_python.version": {
"major": 2,
"micro": 5,
"minor": 7,
"releaselevel": "final",
"serial": 0
}
}
ok: [ans_centos8] => {
"ansible_python.version": {
"major": 3,
"micro": 8,
"minor": 6,
"releaselevel": "final",
"serial": 0
}
}
TASK [debug] **************************************************************************************************************************************
ok: [ans_centos7] => {
"ansible_pkg_mgr": "yum"
}
ok: [ans_centos8] => {
"ansible_pkg_mgr": "dnf"
}
TASK [package] ************************************************************************************************************************************
changed: [ans_centos7]
changed: [ans_centos8]
PLAY RECAP ****************************************************************************************************************************************
ans_centos7 : ok=4 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ans_centos8 : ok=4 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
$ docker stop ans_centos7 ans_centos8
ans_centos7
ans_centos8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment