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

Clarify docs re mode's octal representation #44410

Merged
merged 4 commits into from
Aug 29, 2018
Merged

Clarify docs re mode's octal representation #44410

merged 4 commits into from
Aug 29, 2018

Conversation

lousyd
Copy link
Contributor

@lousyd lousyd commented Aug 20, 2018

I changed the language about how to use mode, calling attention to the
fact that one is adding a zero to mark it as octal to Python, rather
than simply including the zero that one might have put there when using
the chmod command on a Unix command line. This makes it more obvious
that using "01777" is not a typo, because the leading zero is not meant
to reflect the way that number might have been given on a command line.

As pointed out in PEP 3127, "The default octal representation of
integers is silently confusing to people unfamiliar with C-like
languages." That PEP is standards track with final status.

See also: issues #5409 #9196 #11385 #13115 #18952 #23491 #23521

  • Docs Pull Request
ansible 2.6.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/local/lib/python2.7/dist-packages/ara/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]

I changed the language about how to use mode, calling attention to the
fact that one is *adding* a zero to mark it as octal to Python, rather
than simply including the zero that one might have put there when using
the chmod command on a Unix command line. This makes it more obvious
that using "01777" is not a typo, because the leading zero is not meant
to reflect the way that number might have been given on a command line.

As pointed out in PEP 3127, "The default octal representation of
integers is silently confusing to people unfamiliar with C-like
languages." That PEP is standards track with final status.

See also: issues #5409 #9196 #11385 #13115 #18952 #23491 #23521
@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Aug 20, 2018
@webknjaz
Copy link
Member

@lousyd it is strongly advised to fill in the PR template with relevant information when submitting PRs.

@webknjaz webknjaz removed the needs_triage Needs a first human triage before being processed. label Aug 21, 2018
- file:
path: /etc/foo.conf
owner: foo
group: foo
mode: 0644
# when specifying mode using octal numbers, add a leading 0
- file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments should go above the thing they're commenting. you can put it above the mode line, though

@abadger
Copy link
Contributor

abadger commented Aug 21, 2018

@acozine the change here doesn't make it any clearer to me but I'm not against it either. if you like the new wording feel free to merge. if you can think of something better, that would be fine with me as well.

- file:
path: /etc/foo.conf
owner: foo
group: foo
mode: 0644
# when specifying mode using octal numbers, add a leading 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this back where it was, above the mode line, or on the mode line off to the side. Definitely not below.

Copy link
Contributor Author

@lousyd lousyd Aug 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, I meant for that comment to be above the thing it was commenting. In other words, that comment was meant to refer to the next play. But since this is the second mention of it, maybe it's confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-modified lib/ansible/modules/files/file.py to move that comment up above the examples.

Copy link
Contributor

@acozine acozine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this change. While you're clarifying, @lousyd, I'd like to see the next section changed from:
"or quote it (like C('644') or C('0644')"
to be:
"or quote it (like C('644') or C('1777')"
so it's clear that you can either do 01777 or '1777'.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Aug 27, 2018
@@ -79,7 +79,7 @@
'''

EXAMPLES = '''
# change file ownership, group and mode. When specifying mode using octal numbers, first digit should always be 0.
# change file ownership, group and mode. When specifying mode using octal numbers, add a leading 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to put 0 reference just above mode argument:

  # here:
  mode: 0644

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes a lot more sense to me than what I was thinking you wanted. Thank you. I've made that change.

@acozine
Copy link
Contributor

acozine commented Aug 29, 2018

thanks @lousyd for seeing this through!

@acozine acozine merged commit 1247f4a into ansible:devel Aug 29, 2018
@lousyd lousyd deleted the clarify-docs-re-octal-mode branch August 30, 2018 16:11
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants