magfest / reggie-formula

SaltStack formula and dev environment for Reggie, MAGFest's registration and management system
GNU General Public License v3.0
1 stars 6 forks source link

windows: salt doesn't like it when it can't set file permissions, fails build #13

Closed binary1230 closed 5 years ago

binary1230 commented 5 years ago

both myself and @msg4real are seeing this on windows, even after fixing all the other errors in #12

 ID: reggie sideboard configuration
                  Function: file.managed
                      Name: /home/vagrant/reggie-formula/reggie_install/development.ini
                    Result: False
                   Comment: Failed to change mode to 0644
                   Started: 00:53:13.822270
                  Duration: 64.338 ms
                   Changes:
                            ----------
                            diff:
                                New file

my working theory is: chmod 0644 on vboxfs (which shares windows file system into linux) allows you to set the file permission BUT won't actually change it. when you do this, the file permissions stay the same (0755), so I'm guessing that is what it means by "failed to change mode"

I can repro this manually like this:

# file has 777 permission
(env) vagrant@localhost:~/reggie-formula/reggie_install$ stat -c '%a %n' development.ini
777 development.ini

# change to 644 permission
(env) vagrant@localhost:~/reggie-formula/reggie_install$ chmod 0644 development.ini
# no error, but.....

# permission should have changed, didn't
(env) vagrant@localhost:~/reggie-formula/reggie_install$ stat -c '%a %n' development.ini
777 development.ini

So I think we'll probably just need to make the chmod stuff either not verify or not try and change when we're under windows.

binary1230 commented 5 years ago

yea that's what's going on:

set_mode(name, mode)
                    if mode != salt.utils.files.normalize_mode(get_mode(name)):
                        ret['result'] = False
                        ret['comment'].append(
                            'Failed to change mode to {0}'.format(mode)
                        )

in https://github.com/saltstack/salt/blob/d08d65362bc70169d92b899914254da3406294b5/salt/modules/file.py#L4643

binary1230 commented 5 years ago

the solution I found that worked is to just explicitly set the 'mode' attribute to 0777 here, that was the only way to get it to stop complaining.