Initial ansible
							parent
							
								
									4184904fd6
								
							
						
					
					
						commit
						f65b31fd87
					
				| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					*.retry
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					image: python:3.6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					stages:
 | 
				
			||||||
 | 
					  - lint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					yamllint:
 | 
				
			||||||
 | 
					  stage: lint
 | 
				
			||||||
 | 
					  script:
 | 
				
			||||||
 | 
					    - pip install yamllint==1.15.0
 | 
				
			||||||
 | 
					    - yamllint -c .yamllint.yml .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ansible-lint:
 | 
				
			||||||
 | 
					  stage: lint
 | 
				
			||||||
 | 
					  script:
 | 
				
			||||||
 | 
					    - pip install ansible-lint==4.0.0
 | 
				
			||||||
 | 
					    - ansible-lint *.yml
 | 
				
			||||||
 | 
					...
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					extends: default
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rules:
 | 
				
			||||||
 | 
					  line-length:
 | 
				
			||||||
 | 
					    level: warning
 | 
				
			||||||
 | 
					...
 | 
				
			||||||
							
								
								
									
										53
									
								
								README.md
								
								
								
								
							
							
						
						
									
										53
									
								
								README.md
								
								
								
								
							| 
						 | 
					@ -1,3 +1,56 @@
 | 
				
			||||||
# Ansible
 | 
					# Ansible
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Ensemble des recettes de déploiement Ansible pour les serveurs du Crans.
 | 
					Ensemble des recettes de déploiement Ansible pour les serveurs du Crans.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Ces politiques de déployement nécessite Ansible 2.7 ou plus récent.
 | 
				
			||||||
 | 
					Le paquet dans Debian Buster est suffisamment à jour, sinon vous pouvez l'obtenir de la façon suivante :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					pip3 install --user ansible
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Exécution d'un playbook
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Pour appliquer le playbook `base.yml` :
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					ansible-playbook --ask-vault-pass base.yml
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Il est souhaitable de faire un test avant avec `--check` si on a des doutes !
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## FAQ
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Mettre sa clé SSH sur une machine
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					ssh-copy-id -i ~/.ssh/id_rsa_crans.pub zamok.crans.org
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Automatiquement ajouter fingerprint ECDSA (dangereux !)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Il faut changer la variable d'environnement suivante :
 | 
				
			||||||
 | 
					`ANSIBLE_HOST_KEY_CHECKING=0`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Configurer la connexion au bastion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Envoyer son agent SSH peut être dangereux ([source](https://heipei.io/2015/02/26/SSH-Agent-Forwarding-considered-harmful/)).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					On va utiliser plutôt ProxyJump.
 | 
				
			||||||
 | 
					Dans la configuration SSH :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					# Use a key to log on all Aurore servers
 | 
				
			||||||
 | 
					# and use a bastion
 | 
				
			||||||
 | 
					Host 10.231.136.* *.adm.crans.org
 | 
				
			||||||
 | 
					    IdentityFile ~/.ssh/id_rsa_crans
 | 
				
			||||||
 | 
					    ProxyJump passerelle.crans.org
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Il faut savoir que depuis Ansible 2.5, des connexions persistantes sont créées
 | 
				
			||||||
 | 
					vers les serveurs puis détruites à la fin de l'exécution.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Lister tout ce que sait Ansible sur un hôte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					ansible -i hosts zamok.crans.org -m setup --ask-vault-pass
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,29 @@
 | 
				
			||||||
 | 
					# Aurore Crans configuration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[defaults]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Use Aurore inventory
 | 
				
			||||||
 | 
					inventory = ./hosts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Custom header in templates
 | 
				
			||||||
 | 
					ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Do not use cows (with cowsay)
 | 
				
			||||||
 | 
					nocows = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Do more parallelism
 | 
				
			||||||
 | 
					forks = 15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[privilege_escalation]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Use sudo to get priviledge access
 | 
				
			||||||
 | 
					become = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Ask for password
 | 
				
			||||||
 | 
					become_ask_pass = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[diff]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# TO know what changed
 | 
				
			||||||
 | 
					always = yes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					# Crans servers inventory
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# How to name your server ?
 | 
				
			||||||
 | 
					# > We name servers according to location, then type.
 | 
				
			||||||
 | 
					# > So all containers at OVH are in ovh-container.
 | 
				
			||||||
 | 
					# > Then we regroup everything in global geographic and type groups.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[crans-pve]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[crans-container]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[crans-vm]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[ovh-server]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# everything at crans
 | 
				
			||||||
 | 
					[crans:children]
 | 
				
			||||||
 | 
					crans-pve
 | 
				
			||||||
 | 
					crans-container
 | 
				
			||||||
 | 
					crans-vm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# everything at ovh
 | 
				
			||||||
 | 
					[ovh:children]
 | 
				
			||||||
 | 
					ovh-server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# every LXC container
 | 
				
			||||||
 | 
					[container:children]
 | 
				
			||||||
 | 
					crans-container
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# every virtual machine
 | 
				
			||||||
 | 
					[vm:children]
 | 
				
			||||||
 | 
					crans-vm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# every PVE
 | 
				
			||||||
 | 
					[pve:children]
 | 
				
			||||||
 | 
					crans-pve
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue