Installation ansible awx avec certificat ssl sur Ubuntu |
Article original Publié le : 16 octobre 2020 Mise a jour le : – |
Testé sur Ubuntu 20.04
Une interface graphique pour jouer les playbooks
L’avantage de cette interface est de pouvoir faire jouer les playbooks par une tierce personne avec des droits restreints ou pour soit même si on préfère au cli
Préparation de l’environnement
- Mise a jour du système
1 |
$ sudo apt update |
- Installation des paquets nécessaires
1 |
$ sudo apt install apt-transport-https software-properties-common |
- Installation de paquet utile
1 |
$ sudo apt install vim wget pwgen |
- Installation du paquet ansible
1 |
$ sudo apt install ansible |
- Installation de docker
1 |
$ sudo apt install docker.io docker-compose |
Un redémarrage s’impose avant le déploiement d’awx
1 |
$ sudo reboot |
/!\ Au redémarrage vérifier que le service docker est bien démarré, le start et le passer a enable sinon
Déploiement d’awx
A présent cloner le repo awx
1 |
$ git clone https://github.com/ansible/awx.git |
Générer un secret avec pwgen
1 |
$ pwgen 28 1 |
Remplacer le secret_key dans la properties inventory
1 |
$ vim awx/installer/inventory |
On peut aussi changer les properties de db
Et en profiter pour changer le mot de passe admin avant installation
Enfin lancer le playbook d’installation
1 |
$ sudo ansible-playbook -i awx/installer/inventory awx/installer/install.yml |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
... TASK [local_docker : Create ~/.awx/awxcompose directory] ************************************ <span style="color: #ffcc00;">changed: [localhost]</span> TASK [local_docker : Create Redis socket directory] ***************************************** <span style="color: #ffcc00;">changed: [localhost]</span> TASK [local_docker : Create Docker Compose Configuration] *********************************** <span style="color: #ffcc00;">changed: [localhost] => (item={'file': 'environment.sh', 'mode': '0600'}) changed: [localhost] => (item={'file': 'credentials.py', 'mode': '0600'}) changed: [localhost] => (item={'file': 'docker-compose.yml', 'mode': '0600'}) changed: [localhost] => (item={'file': 'nginx.conf', 'mode': '0600'}) changed: [localhost] => (item={'file': 'redis.conf', 'mode': '0664'}) </span> TASK [local_docker : Render SECRET_KEY file] ************************************************ <span style="color: #ffcc00;">changed: [localhost]</span> TASK [local_docker : Start the containers] ************************************************** <span style="color: #ffcc00;">changed: [localhost]</span> TASK [local_docker : Update CA trust in awx_web container] ********************************** <span style="color: #ffcc00;">changed: [localhost]</span> TASK [local_docker : Update CA trust in awx_task container] ********************************* <span style="color: #ffcc00;">changed: [localhost]</span> PLAY RECAP ********************************************************************************** <span style="color: #ffcc00;">localhost</span> : <span style="color: #00ff00;">ok=15</span> <span style="color: #ffcc00;">changed=4</span> unreachable=0 failed=0 <span style="color: #00ffff;">skipped=91</span> rescued=0 ignored=0 |
L’installation est terminé, regardons coté docker ce qui as été généré
1 |
$ sudo docker images |
1 2 3 4 |
REPOSITORY TAG IMAGE ID CREATED SIZE ansible/awx 15.0.0 0e949d548ba2 11 days ago 1.29GB postgres 10 e8abca8f194e 2 weeks ago 200MB redis latest 84c5f6e03bf0 4 weeks ago 104MB |
$ sudo docker ps -a
1 2 3 4 5 6 |
<span style="font-size: 8pt;">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 68b71fbd91c7 ansible/awx:15.0.0 "/usr/bin/tini -- /u…" 41 minutes ago Up 41 minutes 8052/tcp awx_task e8ac582c19b6 ansible/awx:15.0.0 "/usr/bin/tini -- /b…" 41 minutes ago Up 41 minutes 0.0.0.0:80->8052/tcp awx_web aabaefaa9854 redis "docker-entrypoint.s…" 42 minutes ago Up 41 minutes 6379/tcp awx_redis 82e87b891c5b postgres:10 "docker-entrypoint.s…" 42 minutes ago Up 41 minutes 5432/tcp awx_postgres </span> |
Génération du certificat
Le serveur est opérationnel en http mais c’est toujours mieux de sécuriser ces accès avec de l’https surtout si on fait de l’authentification ldap
Pour l’exemple comme toujours j’utilise Let’s Encrypt
Ubuntu 20.04 intègre nativement Cerbot
1 |
$ sudo apt install certbot |
Puis générer le certificat avec le nom de domaine (pensez a librerer les ports 80/443 et ouvrir les acces coté FW)
1 |
$ sudo certbot certonly --standalone -d awx.izero.fr |
Une fois le certificat généré il faut concaténer la clé privé et le certificat vers un fichier bundle
1 |
$ sudo bash -c "cat /etc/letsencrypt/live/awx.izero.fr/privkey.pem /etc/letsencrypt/live/awx.izero.fr/cert.pem > /etc/letsencrypt/live/awx.izero.fr/awx-bundled-key.crt" |
Maintenant on revient sur le fichier inventory pour ajouter le chemin du certificat dans la partie “Common Docker parameters”
1 |
$ vim awx/installer/inventory |
Puis on rejoue le playbook d’installation, cela va surcharger les valeurs d’origines
1 |
$ sudo ansible-playbook -i awx/installer/inventory awx/installer/install.yml |
Se connecter au navigateur avec le compte admin précédemment crée