public:ansible-exemple

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
public:ansible-exemple [2024/10/27 14:05] – [Création d'un fichier d'inventaire] vincent1890public:ansible-exemple [2024/10/27 14:21] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 ====== Ansible-Exemple ====== ====== Ansible-Exemple ======
  
-===== Config réseau =====+===== INVENTAIRE =====
  
-----+==== Création d'un fichier d'inventaire ==== 
 + 
 +  nano inventaire.yml 
 + 
 +<file YAML inventaire.yml> 
 +all: 
 +  vars: 
 +    ansible_python_interpreter: /bin/python3 
 +  children: 
 +    deb_master: 
 +      vars: 
 +        ansible_user: ansible  # Utilisateur pour se connecter en SSH 
 +        dns_redirecteur: 
 +          "10.100.0.3" 
 +          "10.0.0.3" 
 +        allow_query: "10.102.200.0/16"  # Sous-réseau autorisé 
 +        network_interfaces: 
 +          name: "ens33" 
 +            ip_address: "10.102.200.153" 
 +            netmask: "255.255.0.0" 
 +            gateway: "10.102.200.254" 
 +          #- name: "eth1" 
 +          #  ip_address: "192.168.1.10" 
 +          #  netmask: "255.255.255.0" 
 +          #  gateway: "192.168.1.1" 
 +      hosts: 
 +        10.102.200.153: 
 +    deb_slave: 
 +      vars: 
 +        ansible_user: ansible  # Utilisateur pour se connecter en SSH 
 +        dns_redirecteur: 
 +          - "10.100.0.3" 
 +          - "10.0.0.3" 
 +        allow_query: "10.102.200.0/16"  # Sous-réseau autorisé 
 +        network_interfaces: 
 +          - name: "ens33" 
 +            ip_address: "10.102.200.80" 
 +            netmask: "255.255.0.0" 
 +            gateway: "10.102.200.254" 
 +          #- name: "eth1" 
 +          #  ip_address: "192.168.1.10" 
 +          #  netmask: "255.255.255.0" 
 +          #  gateway: "192.168.1.1" 
 +      hosts: 
 +        10.102.200.80: 
 + 
 +</file> 
 + 
 +===== CONFIG - Lan =====
  
 ==== Création d'un PLAYBOOK de config réseau ==== ==== Création d'un PLAYBOOK de config réseau ====
Ligne 68: Ligne 116:
 ---- ----
  
-===== Config Apache2 =====+===== CONFIG - SSH ===== 
 + 
 + 
 +==== Création PLAYBOOK config SSH ==== 
 + 
 +  nano Playbook_Config_SSH.yml 
 + 
 +<file YAML Playbook_Config_SSH.yml> 
 +--- 
 +- name: Playbook pour installer/configurer/sécuriser SSH et installer/configurer BIND 
 +  hosts: all 
 +  become: yes 
 +  tasks: 
 + 
 +    - name: Assurer que le service SSH est installé 
 +      apt: 
 +        name: openssh-server 
 +        state: present 
 +        update_cache: yes 
 + 
 +    - name: Ajouter un bloc de configuration SSH dans /etc/ssh/sshd_config 
 +      ansible.builtin.blockinfile: 
 +        path: /etc/ssh/sshd_config 
 +        backup: true 
 +        insertafter: EOF 
 +        block: | 
 +          # Configuration personnalisée SSH 
 +          Match User ansible 
 +            AllowUsers [email protected] 
 +            PasswordAuthentication no 
 +        marker: "# {mark} Configuration SSH" 
 +        #owner: root 
 +        #group: root 
 +        #mode: '0600' 
 +      notify: 
 +        - Restart SSH 
 + 
 +    - name: Neutraliser la connexion via un accès console de l’utilisateur ansible 
 +      user: 
 +        name: ansible 
 +        password: "!" 
 + 
 +  handlers: 
 +    - name: Restart SSH 
 +      service: 
 +        name: ssh 
 +        state: restarted 
 +</file> 
 + 
 + 
 +===== INSTALL - Apache2 =====
  
 ==== Création PLAYBOOK Apache2 ==== ==== Création PLAYBOOK Apache2 ====
Ligne 97: Ligne 195:
 ---- ----
  
-===== INSTALL et CONFIG Bind9 =====+===== INSTALL CONFIG Bind9 =====
  
 ==== Création PLAYBOOK Bind9 ==== ==== Création PLAYBOOK Bind9 ====
  • public/ansible-exemple.1730034314.txt.gz
  • Dernière modification : 2024/10/27 14:05
  • de vincent1890