Professional Documents
Culture Documents
Elle
combine le déploiement de logiciels multinœuds, l'exécution des tâches ad-hoc et la gestion de
configuration
SETTING UP SSH
Pre-requis :
-OpenSSH installed in Ansible control host and the servers (Create SSH key pair )
Ssh-add
in Gitlab/github : Settings –SSH and GPG keys – New SSH key then add the public key
SETTING UP ANSIBLE
Create a new inventory file in the git rep -> put your servers @ip/name(if u have DNS) in it -> and
commit
Command to make sure everything is working and ansible can establish a connection btw the srvs:
Contains : [defaults]
Inventory = “inventoryFile”
Private_key_file = “cheminAnsibleKey”
Now we can use a shorten command to test because we created the config file :
Ansible all –m ping
Command to fetch infos about a server via ansible : ansible all –m gather_facts –limit “@ip”
CREATING PLAYBOOK
State: absent
CONDITION : WHEN
Use this command to gather facts about a host, that can be used in the when ( when can use the
“and” and “or” operator inside the when ) and make sure that the package name is the right one for
the distribution at hand
Ex: ansible_distribution
---
- hosts: all
become: true
tasks:
package:
name:
- "{{apache package}}"
- "{{php package}}"
state: latest
update_cache: yes
2. Change the inventory file to give value to the variables for each host:
TARGETING SPECIFIC NODES
and then in our playbook .yml file we can specify the groups and what command do we cant to run :
TAGS:
Local file :
Remote file :
MANAGE SERVICES