Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
whoami.yml 720 B
Newer Older
  • Learn to ignore specific revisions
  • ---
    - hosts: "{{ host_list }}"
      become_method: su
      remote_user: root
      become_user: "{{ my_user }}"
    
      tasks:
        - name: Who is «remote_user»
          become: no
          ansible.builtin.script:
            cmd: /usr/bin/whoami
          register: who_is_remote_user
          changed_when: 0
    
        - name: Who is «become_user»
          become: yes
          ansible.builtin.script:
            cmd: /usr/bin/whoami
          register: who_is_become_user
          changed_when: 0
    
        - name: Who is «remote_user»?
          ansible.builtin.debug:
            msg: "I am «{{ who_is_remote_user.stdout_lines }}»"
    
        - name: Who is «become_user»?
          ansible.builtin.debug:
            msg: "I am {{ who_is_become_user.stdout_lines | flatten | first }}"