/etc not writable

1,000 views
Skip to first unread message

Sanjay Kumar

unread,
May 6, 2016, 9:33:15 AM5/6/16
to Ansible Project
Hi,

I am not able copy to remote host, getting not writable error, my playbook  is here.

---
 - hosts: all
   become: yes
   become_user: sanjay
   become_method: sudo
   tasks:
     - name: copy some file
       copy: src=/home/sanjay/messages dest=/etc

================================================
remote host enabled with sudo for user with NOPASSWD: All option
================================================
ansible --version
ansible 2.0.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides



Johannes Kastl

unread,
May 6, 2016, 9:38:42 AM5/6/16
to ansible...@googlegroups.com
On 06.05.16 14:46 Sanjay Kumar wrote:
> Hi,
>
> I am not able copy to remote host, getting not writable error, my playbook
> is here.

> copy: src=/home/sanjay/messages dest=/etc

I am not sure if the copy module is as picky as rsync in regard to
trailing slashes.

...dest=/etc/

Maybe use the full path:

...dest=/etc/messages

Johannes

signature.asc

Sanjay Kumar

unread,
May 6, 2016, 10:28:59 AM5/6/16
to Ansible Project
No luck

Kai Stian Olstad

unread,
May 6, 2016, 11:44:08 AM5/6/16
to ansible...@googlegroups.com
On 06. May 2016 14:46, Sanjay Kumar wrote:
> I am not able copy to remote host, getting not writable error, my playbook
> is here.
>
> ---
> - hosts: all
> become: yes
> become_user: sanjay
> become_method: sudo
> tasks:
> - name: copy some file
> copy: src=/home/sanjay/messages dest=/etc

become_user: sanjay, means Ansible will do a sudo to user sanjay. So
sanjay need permission to the destination.

I guess what you really want is become_user: root , which is the default.

--
Kai Stian Olstad

Sanjay Kumar

unread,
May 9, 2016, 12:17:44 AM5/9/16
to Ansible Project
Thanks Kai Stian Olstad,

I changed as you suggested become_user: root, working now.


On Friday, May 6, 2016 at 7:03:15 PM UTC+5:30, Sanjay Kumar wrote:

Yuriy Buha

unread,
Jul 21, 2017, 9:03:35 AM7/21/17
to Ansible Project, ansible-pr...@olstad.com
Hello. 

I have similar case, and i get this error, but i do need to create it as sudo user. I do not have root privilege.
Can someone please advise?

Thank you

Fayad

unread,
Jul 21, 2017, 9:38:49 AM7/21/17
to ansible...@googlegroups.com
Try these options

Copy the file to the sudo user's home directory or any other directory where the user has got permission.

Or

Increase the permissions of the destination directory so that user can write into that directory.



Fayad

Sent from my OnePlus One

--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d2d870d5-5ff6-4503-9096-0e4a183ae6eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yuriy Buha

unread,
Jul 22, 2017, 8:06:59 AM7/22/17
to Ansible Project
Hi Fayad. 

Thank you for the quick reply. 
I tried to create the file in user's home directory, and then move to the /etc, but then i would get a permission error moving the file to that directory.
It worked after i changed the ownership of /etc from root to the user, but i'm not sure if that's a proper way to do. Is it ok for the /etc directory to be owned by the user but not root?

thank you
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Dick Davies

unread,
Jul 22, 2017, 11:54:06 AM7/22/17
to ansible list
Nope, that's super bad. I thought you didn't have root access?
> https://groups.google.com/d/msgid/ansible-project/78612bcc-e25c-4ee5-9dd0-d5e833a3a696%40googlegroups.com.

Fayad

unread,
Jul 28, 2017, 8:35:30 AM7/28/17
to ansible...@googlegroups.com
Changing ownership of /etc is not a proper way. So you have root access??

Fayad

Sent from my OnePlus One
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/78612bcc-e25c-4ee5-9dd0-d5e833a3a696%40googlegroups.com.

Yuriy Buha

unread,
Aug 1, 2019, 11:16:22 AM8/1/19
to Ansible Project
No, do not have root, but I do have sudo access that allows me to chown of /etc
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages