From a7ae76750cf3258b1d8d86e135522f919a2f452e Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Mon, 23 Jan 2023 15:10:15 +0100 Subject: [PATCH] add sudoers module solution --- Readme.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 8696dd8..da7baf6 100644 --- a/Readme.md +++ b/Readme.md @@ -26,11 +26,21 @@ ansible localhost -m openssh_keypair -a 'path=/home/formation/.ssh/id_rsa owner= #l'inversion des quotes permet l'utilisation du ! dans le mot de passe +```bash ansible cibles -u formation -k -m user -a 'user=ansible password={{ "123Soleil!"| password_hash( "sha512", 65534 | random(seed=inventory_hostname) | string) }} create_home=yes home=/home/ansible' +``` +```bash ansible cibles -u formation -k -m lineinfile -a 'path=/etc/sudoers.d/ansible state=present create=yes line="ansible ALL=(ALL) NOPASSWD: ALL" validate="/usr/sbin/visudo -cf %s"' +``` +```bash ansible cibles -u formation -k -m copy -a 'dest=/etc/sudoers.d/ansible content="ansible ALL=(ALL) NOPASSWD: ALL" validate="/usr/sbin/visudo -cf %s"' +``` +```bash +ansible cibles -o -m community.general.sudoers -a 'name="ansible" user=ansible commands=ALL nopassword=true' +``` +```bash ansible cibles -u formation -k -m authorized_key -a 'key={{ lookup( "file", "~/.ssh/id_rsa.pub") }} user=ansible' - +```