Ansible will be the latest version supporting current Python in OS. So to get latest Ansible , Python must be updated as well!
Warning
Do not update the default Python in OS - it is used by system services, which may break!
Build Python:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
wget https://www.python.org/ftp/python/3.9.15/Python-3.9.15.tgz
tar -xf Python-3.9.15.tgz
cd Python-3.9.15
./configure --enable-optimizations
make -j 8
Installing Python:
Best way is to do checkinstall, create a .deb file to share with the team.
Use altinstall parameter to install Python in an alternative path. This is simpler & better than using Python virtualenv.
sudo make altinstall # now Python 3.9x is installed on separate path, while Python 3.7 in OS is unchangedsudo python3.9 -m pip install --upgrade pip
sudo python3.9 -m pip install ansible
ansible --version # now ansible is the latest version
---- name:front-end playhosts:allgather_facts:yesbecome:yestasks:- name:include role apacheinclude_role:name:apache- name:include role phpinclude_role:name:php...
apache / tasks / main.yml - tasks example:
---- name:install apacheapt:name:apache2- name:Enable service apache2ansible.builtin.systemd:name:apache2enabled:yesmasked:no- name:Make sure apache2 is runningansible.builtin.systemd:state:startedname:apache2...
Role structure
Directories inside a role:
- defaults - variable values by default
-- main.yml
- vars - variables defined by role (for other roles)
-- main.yml
- tasks - jobs to be completed
-- main.yml
- handlers - actions to be taken after checks
-- main.yml
- files - static files to be copied into client machine
- templates