add python-test.yml and re-work the inventory for python fun
This commit is contained in:
@ -14,7 +14,6 @@ forks = 40
|
|||||||
timeout = 30
|
timeout = 30
|
||||||
host_key_checking = False
|
host_key_checking = False
|
||||||
display_skipped_hosts = False
|
display_skipped_hosts = False
|
||||||
interpreter_python = auto_silent
|
|
||||||
bin_ansible_callbacks = True
|
bin_ansible_callbacks = True
|
||||||
callback_whitelist = ansible.posix.profile_tasks, ansible.posix.timer
|
callback_whitelist = ansible.posix.profile_tasks, ansible.posix.timer
|
||||||
deprecation_warnings = False
|
deprecation_warnings = False
|
||||||
|
18
inventory/hosts.new
Normal file
18
inventory/hosts.new
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[dev]
|
||||||
|
lab-dev-1
|
||||||
|
lab-dev-2
|
||||||
|
|
||||||
|
[dev:vars]
|
||||||
|
ansible_python_interpreter=/usr/bin/python2
|
||||||
|
|
||||||
|
|
||||||
|
[prod]
|
||||||
|
lab-prod-1
|
||||||
|
lab-prod-2
|
||||||
|
|
||||||
|
[prod:vars]
|
||||||
|
ansible_python_interpreter=/usr/bin/python3
|
||||||
|
|
||||||
|
|
||||||
|
[all:vars]
|
||||||
|
ansible_user=root
|
46
python-test.yml
Normal file
46
python-test.yml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
- name: install and check python
|
||||||
|
hosts: all
|
||||||
|
become: no
|
||||||
|
gather_facts: yes
|
||||||
|
|
||||||
|
|
||||||
|
vars:
|
||||||
|
install_pkgs: yes
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Debug python interpreter
|
||||||
|
debug:
|
||||||
|
var: ansible_python_interpreter
|
||||||
|
|
||||||
|
|
||||||
|
- name: Install python packages
|
||||||
|
package:
|
||||||
|
name : "{{ item }}"
|
||||||
|
state : present
|
||||||
|
with_items:
|
||||||
|
- python2
|
||||||
|
- python3
|
||||||
|
when:
|
||||||
|
- install_pkgs|bool
|
||||||
|
|
||||||
|
|
||||||
|
- name: Check python version
|
||||||
|
command: "{{ ansible_python_interpreter }} --version"
|
||||||
|
register: r_python_version
|
||||||
|
|
||||||
|
|
||||||
|
- name: Show python 2 version
|
||||||
|
debug:
|
||||||
|
var: r_python_version.stderr
|
||||||
|
when: r_python_version.stderr != ""
|
||||||
|
|
||||||
|
|
||||||
|
- name: Show python 3 version
|
||||||
|
debug:
|
||||||
|
var: r_python_version.stdout
|
||||||
|
when: r_python_version.stdout != ""
|
||||||
|
|
||||||
|
|
||||||
|
...
|
Reference in New Issue
Block a user