Hi All,

I am trying to create a file in /opt folder. My playbook(from test role) 
looks like,

---
> - name: create file
>   file:
>     path: /opt/testfile
>     state: touch
>

And main.yml looks like,


---
> - hosts: '{{ host }}'
>   become: yes
>   become_method: sudo
>   become_user: jenkins
>   roles:
>    - test


I am running the playbook as,

ansible-playbook -i /tmp/ansible-workspace/environments/QA/inventory 
> --extra-vars "host=QA"  --ask-pass --ask-become-pass main.yml -vvv


And the error I get is,

 "mode": "0644",
    "msg": "Error while touching existing target: [Errno 13] Permission 
denied: '/opt/testfile'",
    "owner": "root",
    "path": "/opt/testfile",
    "secontext": "unconfined_u:object_r:etc_t:s0",
    "size": 0,
    "state": "file",
    "uid": 0
 
But when I comment out the line become_user: jenkins in main.yml and run it 
with the command 
 

> ansible-playbook -i /tmp/ansible-workspace/environments/QA/inventory 
> --extra-vars "host=QA" -u jenkins --ask-pass --ask-become-pass main.yml -vvv


it works perfectly fine.

Can someone please say teh differnce between the two ways?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/224db57f-14a2-4b7b-87cf-6606494b6df5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to