From c3065341f41e190d5906c327fa158143f6dd5781 Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Tue, 18 Nov 2025 10:07:07 +0100 Subject: [PATCH] Added become_method become_user --- training/become_method.yml | 12 ++++++++++++ training/become_user.yml | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 training/become_method.yml create mode 100644 training/become_user.yml diff --git a/training/become_method.yml b/training/become_method.yml new file mode 100644 index 0000000..4520c22 --- /dev/null +++ b/training/become_method.yml @@ -0,0 +1,12 @@ +- name: Usar su en lugar de sudo + hosts: all + become: yes + become_method: su + tasks: + - name: Verificar el usuario actual + command: whoami + register: resultado + + - name: Mostrar el usuario actual + debug: + msg: "El usuario actual es {{ resultado.stdout }}" \ No newline at end of file diff --git a/training/become_user.yml b/training/become_user.yml new file mode 100644 index 0000000..64fb52b --- /dev/null +++ b/training/become_user.yml @@ -0,0 +1,9 @@ +- name: ejecutar tareas con un usuario especifico + hosts: all + become: yes + become_user: postgres + tasks: + - name: Crear base de datos + postgresql_db: + name: mi_base_de_datos + state: present \ No newline at end of file