64 lines
1.0 KiB
YAML
64 lines
1.0 KiB
YAML
---
|
|
- name: install and check python
|
|
hosts: all
|
|
gather_facts: yes
|
|
become: yes
|
|
|
|
|
|
vars:
|
|
install_pkgs: yes
|
|
|
|
|
|
tasks:
|
|
- name: Install python packages
|
|
package :
|
|
name : "{{ item }}"
|
|
state : present
|
|
with_items:
|
|
- python2
|
|
- python3
|
|
when:
|
|
- install_pkgs|bool
|
|
|
|
|
|
- name: Debug python interpreter
|
|
debug:
|
|
var: ansible_python_interpreter
|
|
|
|
|
|
- name: Check Python version
|
|
debug:
|
|
var: ansible_python_version
|
|
|
|
|
|
- name: Check executable
|
|
debug:
|
|
var: ansible_python.executable
|
|
|
|
|
|
- name: Deploy sample script
|
|
copy:
|
|
src : files/pytest.py
|
|
dest : /tmp/pytest.py
|
|
mode : 0755
|
|
|
|
|
|
- name: Execute sample script
|
|
command : "{{ ansible_python.executable }} /tmp/pytest.py"
|
|
register : r_sample_script
|
|
|
|
|
|
- name: Show r_sample_script
|
|
debug:
|
|
var: r_sample_script
|
|
|
|
|
|
- name: Cleanup sample script
|
|
file:
|
|
path : /tmp/pytest.py
|
|
state : absent
|
|
|
|
|
|
|
|
...
|