This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docpublic:systemes:ansible_init [2022/08/20 09:57] adminjp [ansible module apt] |
docpublic:systemes:ansible_init [2022/08/21 08:49] (current) adminjp [ansible module ssh] |
||
---|---|---|---|
Line 1630: | Line 1630: | ||
stat_fileR ----------------------------------------------------------------------------------- 0.30s | stat_fileR ----------------------------------------------------------------------------------- 0.30s | ||
create_fileR --------------------------------------------------------------------------------- 0.29s | create_fileR --------------------------------------------------------------------------------- 0.29s | ||
+ | </ | ||
+ | |||
+ | ==== ansible module ssh ==== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | genérer une clée ssh et la deployer | ||
+ | |||
+ | < | ||
+ | ans@disi-dellat: | ||
+ | --- | ||
+ | - name: J_Playbook_sshKey | ||
+ | hosts: node3 | ||
+ | become: yes | ||
+ | tasks: | ||
+ | - name: create_sshKey | ||
+ | openssh_keypair: | ||
+ | path: "/ | ||
+ | type: rsa | ||
+ | size: 2048 | ||
+ | state: present | ||
+ | force: no | ||
+ | #delegate a localhost pour jouer ça sur notre server-node | ||
+ | delegate_to: | ||
+ | #le faire tourner une seule fois , meme si +sieurs hosts | ||
+ | run_once: yes | ||
+ | </ | ||
+ | |||
+ | === execution === | ||
+ | |||
+ | < | ||
+ | ans@disi-dellat: | ||
+ | BECOME password: | ||
+ | |||
+ | PLAY [J_Playbook_sshKey] **************************************************************************** | ||
+ | |||
+ | TASK [Gathering Facts] ****************************************************************************** | ||
+ | Saturday 20 August 2022 20:45:52 +0200 (0: | ||
+ | ok: [node3] | ||
+ | |||
+ | TASK [create_sshKey] ******************************************************************************** | ||
+ | Saturday 20 August 2022 20:45:53 +0200 (0: | ||
+ | changed: [node3 -> localhost] | ||
+ | |||
+ | PLAY RECAP ****************************************************************************************** | ||
+ | node3 : ok=2 changed=1 | ||
+ | |||
+ | Saturday 20 August 2022 20:45:53 +0200 (0: | ||
+ | =============================================================================== | ||
+ | Gathering Facts ------------------------------------------------------------------------------ 0.86s | ||
+ | create_sshKey -------------------------------------------------------------------------------- 0.21s | ||
+ | |||
+ | ans@disi-dellat: | ||
+ | -rw-r--r-- 1 root root 382 août 20 20:45 / | ||
+ | -rw------- 1 root root 1799 août 20 20:45 / | ||
+ | </ | ||
+ | |||
+ | ==== deploy ssh-key ==== | ||
+ | |||
+ | apres generation locale de la clé (pas besoin d' | ||
+ | |||
+ | < | ||
+ | ans@disi-dellat: | ||
+ | --- | ||
+ | - name: J_Playbook_sshKey | ||
+ | hosts: node3 | ||
+ | become: yes | ||
+ | tasks: | ||
+ | - name: create_sshKey | ||
+ | openssh_keypair: | ||
+ | path: "/ | ||
+ | type: rsa | ||
+ | size: 2048 | ||
+ | state: present | ||
+ | force: no | ||
+ | #delegate a localhost pour jouer ça sur notre server-node | ||
+ | delegate_to: | ||
+ | #le faire tourner une seule fois , meme si +sieurs hosts | ||
+ | run_once: yes | ||
+ | |||
+ | - name: create_user_adma | ||
+ | user: | ||
+ | name: adma | ||
+ | shell: /bin/bash | ||
+ | groups: sudo | ||
+ | append: yes | ||
+ | password: "{{ ' | ||
+ | become: yes | ||
+ | |||
+ | - name: add_adma_sudoers | ||
+ | copy: | ||
+ | dest: "/ | ||
+ | content: "adma ALL=(ALL) NOPASSWD: ALL" | ||
+ | become: yes | ||
+ | |||
+ | - name: deploy_sshKey | ||
+ | authorized_key: | ||
+ | user: adma | ||
+ | key: "{{ lookup(' | ||
+ | state: present | ||
+ | become: yes | ||
+ | </ | ||
+ | |||
+ | === execution === | ||
+ | |||
+ | < | ||
+ | ans@disi-dellat: | ||
+ | BECOME password: | ||
+ | |||
+ | PLAY [J_Playbook_sshKey] **************************************************************************** | ||
+ | |||
+ | TASK [Gathering Facts] ****************************************************************************** | ||
+ | Sunday 21 August 2022 10:47:05 +0200 (0: | ||
+ | ok: [node3] | ||
+ | |||
+ | TASK [create_sshKey] ******************************************************************************** | ||
+ | Sunday 21 August 2022 10:47:06 +0200 (0: | ||
+ | ok: [node3 -> localhost] | ||
+ | |||
+ | TASK [create_user_adma] ***************************************************************************** | ||
+ | Sunday 21 August 2022 10:47:06 +0200 (0: | ||
+ | changed: [node3] | ||
+ | |||
+ | TASK [add_adma_sudoers] ***************************************************************************** | ||
+ | Sunday 21 August 2022 10:47:07 +0200 (0: | ||
+ | ok: [node3] | ||
+ | |||
+ | TASK [deploy_sshKey] ******************************************************************************** | ||
+ | Sunday 21 August 2022 10:47:07 +0200 (0: | ||
+ | changed: [node3] | ||
+ | |||
+ | PLAY RECAP ****************************************************************************************** | ||
+ | node3 : ok=5 changed=2 | ||
+ | |||
+ | Sunday 21 August 2022 10:47:08 +0200 (0: | ||
+ | =============================================================================== | ||
+ | Gathering Facts ------------------------------------------------------------------------------ 1.25s | ||
+ | deploy_sshKey -------------------------------------------------------------------------------- 0.66s | ||
+ | add_adma_sudoers ----------------------------------------------------------------------------- 0.62s | ||
+ | create_user_adma ----------------------------------------------------------------------------- 0.50s | ||
+ | create_sshKey -------------------------------------------------------------------------------- 0.19s | ||
</ | </ |