root@raspberrypi:~# pip3 install --upgrade pip
Successfully installed pip-21.1.2
root@raspberrypi:~# pip -V
pip 21.1.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)
root@raspberrypi:~# mkdir -p /var/app/ansible
root@raspberrypi:/var/app/ansible# python3 -V
Python 3.7.3
root@raspberrypi:/var/app/ansible# python3 -m venv .venv
root@raspberrypi:/var/app/ansible# . .venv/bin/activate
(.venv) root@raspberrypi:/var/app/ansible#
(.venv) root@raspberrypi:/var/app/ansible# pip install --upgrade pip setuptools
(.venv) root@raspberrypi:/var/app/ansible# pip install ansible
Successfully installed MarkupSafe-2.0.1 PyYAML-5.4.1 ansible-4.1.0 ansible-core-2.11.1 cffi-1.14.5 cryptography-3.4.7 jinja2-3.0.1 packaging-20.9 pycparser-2.20 pyparsing-2.4.7 resolvelib-0.5.4
(.venv) root@raspberrypi:/var/app/ansible# ansible --version
ansible [core 2.11.1]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /var/app/ansible/.venv/lib/python3.7/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /var/app/ansible/.venv/bin/ansible
python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
jinja version = 3.0.1
libyaml = True
root@raspberrypi:~# apt-get update
root@raspberrypi:~# apt-get upgrade
root@raspberrypi:/var/app/ansible# apt install git
root@raspberrypi:/var/app/ansible# git --version
git version 2.20.1
root@raspberrypi:/var/app/ansible# git config --global user.email "XXXX@gmail.com"
root@raspberrypi:/var/app/ansible# git config --global user.name "XXXX"
root@raspberrypi:/var/app/ansible# git remote add origin https://github.com/XXXX/ansible
root@raspberrypi:/var/app/ansible# git pull origin master
root@raspberrypi:/var/app/ansible# vi /etc/hosts
root@raspberrypi:/var/app/ansible# cat /etc/hosts
...
192.168.1.11 rasp-pi01.home
192.168.1.12 rasp-pi02.home
192.168.1.13 rasp-pi03.home
root@raspberrypi:/var/app/ansible# mkdir -p environments/home
root@raspberrypi:/var/app/ansible# vi environments/home/hosts
root@raspberrypi:/var/app/ansible# cat environments/home/hosts
root@raspberrypi:/var/app/ansible# cat environments/home/hosts
...
[all:vars]
ansible_ssh_user=root
ansible_ssh_private_key_file=/root/.ssh/id_rsa
ansible_python_interpreter=/usr/bin/python3
[rasp-pi01]
rasp-pi01.home
[rasp-pi02]
rasp-pi02.home
[rasp-pi03]
rasp-pi03.home
(.venv) root@raspberrypi:/var/app/ansible# ansible -i environments/home/hosts all -m ping
rasp-pi01.home | SUCCESS => {
"changed": false,
"ping": "pong"
}
rasp-pi02.home | SUCCESS => {
"changed": false,
"ping": "pong"
}
rasp-pi03.home | SUCCESS => {
"changed": false,
"ping": "pong"
}
(.venv) root@raspberrypi:/var/app/ansible# pip freeze > requirements.txt
(.venv) root@raspberrypi:/var/app/ansible# cat requirements.txt
ansible==4.1.0
ansible-core==2.11.1
cffi==1.14.5
cryptography==3.4.7
Jinja2==3.0.1
MarkupSafe==2.0.1
packaging==20.9
pkg-resources==0.0.0
pycparser==2.20
pyparsing==2.4.7
PyYAML==5.4.1
resolvelib==0.5.4