On Tue, Apr 2, 2019 at 4:57 PM Callum Smith <callum@well.ox.ac.uk> wrote:
Re-running same config sorted this error... Though we're back here:

- Clean NFS
- Task run as normal user
- name: Install oVirt Hosted Engine
  roles:
    - ovirt.hosted_engine_setup
- No overrides in ansible.cfg
- ansible_user=root set inside /etc/ansible/hosts

I can't see the command actually trying to do any sudo command for the `dd` - but it's clearly in the playbook it should be running the command as `vdsm` - is there an obvious next-step?



I tried isolating it and, at least with ansible 2.7.8, everything works exactly as expected: become at task level wins over playbook or role one.

Honestly I've no idea on why if fails on your have.
Do you have any customization to that role?


[stirabos@ansiblec ~]$ ansible --version
ansible 2.7.8
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/stirabos/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
[stirabos@ansiblec ~]$ cat roles/test_role/tasks/main.yml 
---
- name: test become behaviour
  command: whoami
  become: true
  become_user: vdsm
  become_method: sudo
  register: whoamiout
- debug: var=whoamiout.stdout
[stirabos@ansiblec ~]$ cat test1.yml 
---
- name: Test role
  hosts: c76he20190321h1.localdomain
  become: yes
  become_user: root
  roles:
    - role: test_role
[stirabos@ansiblec ~]$ cat test2.yml 
---
- name: Test role
  hosts: c76he20190321h1.localdomain
  roles:
    - role: test_role
      become: yes
      become_user: root
[stirabos@ansiblec ~]$ ansible-playbook -i c76he20190321h1.localdomain, test1.yml

PLAY [Test role] *************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************************************************************
ok: [c76he20190321h1.localdomain]

TASK [test_role : test become behaviour] *************************************************************************************************************************************************************************************************************************************************
changed: [c76he20190321h1.localdomain]

TASK [test_role : debug] *****************************************************************************************************************************************************************************************************************************************************************
ok: [c76he20190321h1.localdomain] => {
    "whoamiout.stdout": "vdsm"
}

PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************************
c76he20190321h1.localdomain : ok=3    changed=1    unreachable=0    failed=0   

[stirabos@ansiblec ~]$ ansible-playbook -i c76he20190321h1.localdomain, test2.yml

PLAY [Test role] *************************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************************************************************
ok: [c76he20190321h1.localdomain]

TASK [test_role : test become behaviour] *************************************************************************************************************************************************************************************************************************************************
changed: [c76he20190321h1.localdomain]

TASK [test_role : debug] *****************************************************************************************************************************************************************************************************************************************************************
ok: [c76he20190321h1.localdomain] => {
    "whoamiout.stdout": "vdsm"
}

PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************************
c76he20190321h1.localdomain : ok=3    changed=1    unreachable=0    failed=0