Différences
Ci-dessous, les différences entre deux révisions de la page.
| 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] – [Config réseau] vincent1890 | public:ansible-exemple [2024/10/27 14:21] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== Ansible-Exemple ====== | ====== Ansible-Exemple ====== | ||
| - | ===== Config | + | ===== INVENTAIRE ===== |
| + | |||
| + | ==== Création d'un fichier d' | ||
| + | |||
| + | nano inventaire.yml | ||
| + | |||
| + | <file YAML inventaire.yml> | ||
| + | all: | ||
| + | vars: | ||
| + | ansible_python_interpreter: | ||
| + | children: | ||
| + | deb_master: | ||
| + | vars: | ||
| + | ansible_user: | ||
| + | dns_redirecteur: | ||
| + | - " | ||
| + | - " | ||
| + | allow_query: | ||
| + | network_interfaces: | ||
| + | - name: " | ||
| + | ip_address: " | ||
| + | netmask: " | ||
| + | gateway: " | ||
| + | #- name: " | ||
| + | # ip_address: " | ||
| + | # netmask: " | ||
| + | # gateway: " | ||
| + | hosts: | ||
| + | 10.102.200.153: | ||
| + | deb_slave: | ||
| + | vars: | ||
| + | ansible_user: | ||
| + | dns_redirecteur: | ||
| + | - " | ||
| + | - " | ||
| + | allow_query: | ||
| + | network_interfaces: | ||
| + | - name: " | ||
| + | ip_address: " | ||
| + | netmask: " | ||
| + | gateway: " | ||
| + | #- name: " | ||
| + | # ip_address: " | ||
| + | # netmask: " | ||
| + | # gateway: " | ||
| + | hosts: | ||
| + | 10.102.200.80: | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== CONFIG - Lan ===== | ||
| ==== Création d'un PLAYBOOK de config réseau ==== | ==== Création d'un PLAYBOOK de config réseau ==== | ||
| Ligne 66: | Ligne 116: | ||
| ---- | ---- | ||
| - | ===== Config | + | ===== CONFIG - SSH ===== |
| + | |||
| + | |||
| + | ==== Création PLAYBOOK config SSH ==== | ||
| + | |||
| + | nano Playbook_Config_SSH.yml | ||
| + | |||
| + | <file YAML Playbook_Config_SSH.yml> | ||
| + | --- | ||
| + | - name: Playbook pour installer/ | ||
| + | hosts: all | ||
| + | become: yes | ||
| + | tasks: | ||
| + | |||
| + | - name: Assurer que le service SSH est installé | ||
| + | apt: | ||
| + | name: openssh-server | ||
| + | state: present | ||
| + | update_cache: | ||
| + | |||
| + | - name: Ajouter un bloc de configuration SSH dans / | ||
| + | ansible.builtin.blockinfile: | ||
| + | path: / | ||
| + | backup: true | ||
| + | insertafter: | ||
| + | block: | | ||
| + | # Configuration personnalisée SSH | ||
| + | Match User ansible | ||
| + | AllowUsers [email protected] | ||
| + | PasswordAuthentication no | ||
| + | marker: "# {mark} Configuration SSH" | ||
| + | #owner: root | ||
| + | #group: root | ||
| + | #mode: ' | ||
| + | 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 | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== INSTALL - Apache2 ===== | ||
| ==== Création PLAYBOOK Apache2 ==== | ==== Création PLAYBOOK Apache2 ==== | ||
| Ligne 95: | Ligne 195: | ||
| ---- | ---- | ||
| - | ===== INSTALL | + | ===== INSTALL |
| ==== Création PLAYBOOK Bind9 ==== | ==== Création PLAYBOOK Bind9 ==== | ||