Cygwin is a real PITA in relation to windows permissions. I hate it. But, it's doable.
On Tuesday, March 13, 2018 at 1:27:24 PM UTC-7, lpesc...@google.com wrote: > > Hi, all. > I have an issue with a certain script (permissions) whilst using ansible. > First of all, I have one script that does work: > > *#!/bin/bash* > > *set -xe* > > *chmod 660 /etc/rsyncd.secrets* > *mkpasswd > /etc/passwd* > *sed -i 's/^YRunner/yrunner/' /etc/passwd* > > I run it with this command set in the playbook: > > *- name: Run chmod script* > * win_command: 'cmd.exe /c "start C:\cygwin\bin\bash.exe > /cygdrive/c/TEMP/chmod1.sh"'* > * become: yes* > * become_method: runas* > * become_user: SYSTEM* > > And the expected result is achieved: > > *$ stat /etc/rsyncd.secrets* > * File: /etc/rsyncd.secrets* > * Size: 17 Blocks: 1 IO Block: 65536 regular file* > *Device: d22da4adh/3526206637d Inode: 9288674231979766 Links: 1* > *Access: (0660/-rw-rw----) Uid: ( 544/Administrators) Gid: (197121/ > None)* > *Access: 2018-03-13 08:26:32.696649400 -0700* > *Modify: 2018-03-13 08:26:31.182425000 -0700* > *Change: 2018-03-13 13:14:37.662372900 -0700* > * Birth: 2018-03-13 08:26:32.696649400 -0700* > > However, when I run THIS script: > > *#!/bin/bash* > > *set -xe* > > *chmod 700 -R ~/.ssh* > *chmod 700 -R /home/YRunner* > *chown yrunner -R /home/YRunner* > *chmod 600 -R ~/.ssh/authorized_keys* > > With this command set in the playbook: > > *- name: Run chmod script 2* > * win_command: 'cmd.exe /c "start C:\cygwin\bin\bash.exe > /cygdrive/c/TEMP/chmod2.sh"'* > * become: yes* > * become_method: runas* > * become_user: SYSTEM* > > I do NOT get the expected result: > > *$ stat ~/.ssh* > * File: /home/YRunner/.ssh* > * Size: 0 Blocks: 0 IO Block: 65536 directory* > *Device: d22da4adh/3526206637d Inode: 8162774325137173 Links: 1* > *Access: (0777/drwxrwxrwx) Uid: (197609/ YRunner) Gid: (197121/ > None)* > *Access: 2018-03-13 08:32:35.164358900 -0700* > *Modify: 2018-03-13 08:32:35.164358900 -0700* > *Change: 2018-03-13 13:24:24.376928300 -0700* > * Birth: 2018-03-13 08:27:52.540239800 -0700* > > But, when I run this script as admin from cygwin, it works. > > *$ ./chmod2.sh* > *+ chmod 700 -R /home/YRunner/.ssh* > *+ chmod 700 -R /home/YRunner* > *+ chown yrunner -R /home/YRunner* > *+ chmod 600 -R /home/YRunner/.ssh/authorized_keys* > > *YRunner@YRUNNERW-01 /cygdrive/c/TEMP* > *$ stat ~/.ssh* > * File: /home/YRunner/.ssh* > * Size: 0 Blocks: 0 IO Block: 65536 directory* > *Device: d22da4adh/3526206637d Inode: 8162774325137173 Links: 1* > *Access: (0700/drwx------) Uid: (197609/ YRunner) Gid: (197121/ > None)* > *Access: 2018-03-13 08:32:35.164358900 -0700* > *Modify: 2018-03-13 08:32:35.164358900 -0700* > *Change: 2018-03-13 13:25:32.829368400 -0700* > * Birth: 2018-03-13 08:27:52.540239800 -0700* > > *The difference I see is that the Uid on the working script is > Administrator, while the non-working script Uid is YRunner (my user).* > > *What am I doing wrong? Can I adjust my script in any way to make these > mods happen?* > > -- 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+unsubscr...@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/9b3119a3-3bad-4fd3-bf16-5ca5d0bb76af%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.