Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing mode of static files #192

Merged
merged 1 commit into from
Apr 15, 2023
Merged

Allow changing mode of static files #192

merged 1 commit into from
Apr 15, 2023

Conversation

hexylena
Copy link
Member

for e.g. welcome.html to be readable by nginx

@hexylena
Copy link
Member Author

148 ubuntu@gat-8:~/git-gat$ ls -al files/galaxy/themes.yml 
-rw-rw-r-- 1 ubuntu ubuntu 1654 Apr 14 11:55 files/galaxy/themes.yml
ubuntu@gat-8:~/git-gat$ ls -al /srv/galaxy/config/themes.yml
-r----xrw- 1 root galaxy 1654 Apr 14 11:56 /srv/galaxy/config/themes.yml

yeah that's relevant. And wow what bizarre permissions.

I'm guessing because internally we have an octal number (which yaml parses as a number) for galaxy_config_perms,

>>> yaml.load("test: 0640")
{'test': 416}

yeah that's that nonsense for sure.

@hexylena
Copy link
Member Author

ubuntu@gat-8:~/git-gat$ ansible -m copy -a 'content=galaxy.yml dest=out.txt mode="{{ \"%#o\" % ((\"0640\" | int^C|default(galaxy_config_perms)) }}"' -i hosts localhost -e @roles/galaxyproject.galaxy/defaults/main.yml

was the closest I got but that's still...very wrong. so I'll separate out the tasks.

@hexylena
Copy link
Member Author

This is...probably better.

@kysrpex
Copy link

kysrpex commented Apr 14, 2023

Thanks for fixing this, I was using a post task up to now.

@hexylena
Copy link
Member Author

@kysrpex which files were you using it for? (i.e. is there something in the training that should have more readable permissions?)

@kysrpex
Copy link

kysrpex commented Apr 14, 2023

@kysrpex which files were you using it for? (i.e. is there something in the training that should have more readable permissions?)

The welcome page :)

@natefoo
Copy link
Member

natefoo commented Apr 14, 2023

How is it not parsing the defaults as octal? I'm never clear on when it does and doesn't. But seems like we should just quote both of them to be explicit that they are not octal?

@hexylena hexylena merged commit c96682c into main Apr 15, 2023
15 checks passed
@hexylena
Copy link
Member Author

How is it not parsing the defaults as octal?

It does, directly into an int (416). So if that gets turned into a string (as happens via "{{ ... }}") then it gets mis-interpreted. As far as I can tell there's no way to tell ansible "hey this is actually an int even though you wanted it quoted because it's a templated var".

Which means it's probably... impossible?

I'm never clear on when it does and doesn't. But seems like we should just quote both of them to be explicit that they are not octal?

0NNN (parse by yaml), "0NNN" (parsed by ansible) both get turned into octals, "NNN" also for some reason gets interpreted as octal, rather than anything else. from the docs:

For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like 0644 or 01777)or quote it (like '644' or '1777') so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants