Merge ~d-info-e/cloud-init:fix-user-group-doc into cloud-init:master
- Git
- lp:~d-info-e/cloud-init
- fix-user-group-doc
- Merge into master
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Chad Smith | ||||
Approved revision: | 4b892c2d1fa97bb35935f351d65c872bde513ebf | ||||
Merge reported by: | Chad Smith | ||||
Merged at revision: | b27f713ae5b4c5b38eda63758dbaeab92be13b9d | ||||
Proposed branch: | ~d-info-e/cloud-init:fix-user-group-doc | ||||
Merge into: | cloud-init:master | ||||
Diff against target: |
242 lines (+44/-44) 7 files modified
cloudinit/config/cc_users_groups.py (+14/-14) doc/examples/cloud-config-user-groups.txt (+12/-12) tests/cloud_tests/testcases/examples/including_user_groups.yaml (+1/-1) tests/cloud_tests/testcases/modules/user_groups.yaml (+1/-1) tests/data/merge_sources/expected7.yaml (+8/-8) tests/data/merge_sources/source7-1.yaml (+5/-5) tests/data/merge_sources/source7-2.yaml (+3/-3) |
||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Server Team CI bot | continuous-integration | Approve | |
Chad Smith | Approve | ||
Review via email: mp+342251@code.launchpad.net |
Commit message
correct documentation to match correct attribute name usage.
LP: #1420018
Description of the change
Scott Moser (smoser) wrote : | # |
do3meli (d-info-e) wrote : | # |
i haven't tested it but just looking at the code i assume you think that line 133 is the one that converts '-' into '_', right?
see https:/
it definitely makes sense to be consistent in the docs as well as the actual implementation. so i will make sure that cloudinit/
on the other hand i am unsure if ssh-import-id and ssh-authorized-keys are identical. i will dig into that further later on.
- c6493bb... by do3meli
-
adjust also inline code docs for cc_user_groups
do3meli (d-info-e) wrote : | # |
hi scott,
i have addressed your point 2), but not yet 1) as i am still unsure if it will break something or not. looking at it a bit more closer i believe any '-' in the cc_user_group module should be replaced if it really works both ways. that also would include others like primary-group, selinux-user, ect. see cloud-config-
Scott Moser (smoser) wrote : | # |
I'm pretty sure it does work both ways.
so yeah, i suggest we change everything there to have _.
Chad Smith (chad.smith) wrote : | # |
+1 on changing any hyphenat-delimited keys to underscore-
Dominic, I'll await your final pass on this and we'll land it right away. Thx again.
Chad Smith (chad.smith) : | # |
Chad Smith (chad.smith) wrote : | # |
When you update docs, it's probably good to replace
primary-group: foobar with
with
primary_group: foobar
in our integration test @ tests/cloud_
do3meli (d-info-e) wrote : | # |
i will grep through the whole repo when changing a key so i won't miss any place. will keep you updated on this once having time to fix them all.
do3meli (d-info-e) wrote : | # |
just found this old bug report here: https:/
matches perfectly but is even more general i guess.
- 4b892c2... by do3meli
-
change all - to _ in tests,modules,doc for user-group module
do3meli (d-info-e) wrote : | # |
chad,
i have adjusted all other occurrence i found. the ssh-import-id was a bit tricky as we have a module called the same. you may have a closer look at this one specifically.
please run CI. thanks
Server Team CI bot (server-team-bot) wrote : | # |
PASSED: Continuous integration, rev:4b892c2d1fa
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild:
https:/
Chad Smith (chad.smith) wrote : | # |
An upstream commit landed for this bug.
To view that commit see the following URL:
https:/
Preview Diff
1 | diff --git a/cloudinit/config/cc_users_groups.py b/cloudinit/config/cc_users_groups.py | |||
2 | index f363000..b215e95 100644 | |||
3 | --- a/cloudinit/config/cc_users_groups.py | |||
4 | +++ b/cloudinit/config/cc_users_groups.py | |||
5 | @@ -34,16 +34,16 @@ config keys for an entry in ``users`` are as follows: | |||
6 | 34 | - ``homedir``: Optional. Home dir for user. Default is ``/home/<username>`` | 34 | - ``homedir``: Optional. Home dir for user. Default is ``/home/<username>`` |
7 | 35 | - ``inactive``: Optional. Mark user inactive. Default: false | 35 | - ``inactive``: Optional. Mark user inactive. Default: false |
8 | 36 | - ``lock_passwd``: Optional. Disable password login. Default: true | 36 | - ``lock_passwd``: Optional. Disable password login. Default: true |
10 | 37 | - ``no-create-home``: Optional. Do not create home directory. Default: | 37 | - ``no_create_home``: Optional. Do not create home directory. Default: |
11 | 38 | false | 38 | false |
13 | 39 | - ``no-log-init``: Optional. Do not initialize lastlog and faillog for | 39 | - ``no_log_init``: Optional. Do not initialize lastlog and faillog for |
14 | 40 | user. Default: false | 40 | user. Default: false |
16 | 41 | - ``no-user-group``: Optional. Do not create group named after user. | 41 | - ``no_user_group``: Optional. Do not create group named after user. |
17 | 42 | Default: false | 42 | Default: false |
18 | 43 | - ``passwd``: Hash of user password | 43 | - ``passwd``: Hash of user password |
20 | 44 | - ``primary-group``: Optional. Primary group for user. Default to new group | 44 | - ``primary_group``: Optional. Primary group for user. Default to new group |
21 | 45 | named after user. | 45 | named after user. |
23 | 46 | - ``selinux-user``: Optional. SELinux user for user's login. Default to | 46 | - ``selinux_user``: Optional. SELinux user for user's login. Default to |
24 | 47 | default SELinux user. | 47 | default SELinux user. |
25 | 48 | - ``shell``: Optional. The user's login shell. The default is to set no | 48 | - ``shell``: Optional. The user's login shell. The default is to set no |
26 | 49 | shell, which results in a system-specific default being used. | 49 | shell, which results in a system-specific default being used. |
27 | @@ -51,9 +51,9 @@ config keys for an entry in ``users`` are as follows: | |||
28 | 51 | a Snappy user through ``snap create-user``. If an Ubuntu SSO account is | 51 | a Snappy user through ``snap create-user``. If an Ubuntu SSO account is |
29 | 52 | associated with the address, username and SSH keys will be requested from | 52 | associated with the address, username and SSH keys will be requested from |
30 | 53 | there. Default: none | 53 | there. Default: none |
32 | 54 | - ``ssh-authorized-keys``: Optional. List of ssh keys to add to user's | 54 | - ``ssh_authorized_keys``: Optional. List of ssh keys to add to user's |
33 | 55 | authkeys file. Default: none | 55 | authkeys file. Default: none |
35 | 56 | - ``ssh-import-id``: Optional. SSH id to import for user. Default: none | 56 | - ``ssh_import_id``: Optional. SSH id to import for user. Default: none |
36 | 57 | - ``sudo``: Optional. Sudo rule to use, or list of sudo rules to use. | 57 | - ``sudo``: Optional. Sudo rule to use, or list of sudo rules to use. |
37 | 58 | Default: none. | 58 | Default: none. |
38 | 59 | - ``system``: Optional. Create user as system user with no home directory. | 59 | - ``system``: Optional. Create user as system user with no home directory. |
39 | @@ -89,18 +89,18 @@ config keys for an entry in ``users`` are as follows: | |||
40 | 89 | homedir: <home directory> | 89 | homedir: <home directory> |
41 | 90 | inactive: <true/false> | 90 | inactive: <true/false> |
42 | 91 | lock_passwd: <true/false> | 91 | lock_passwd: <true/false> |
46 | 92 | no-create-home: <true/false> | 92 | no_create_home: <true/false> |
47 | 93 | no-log-init: <true/false> | 93 | no_log_init: <true/false> |
48 | 94 | no-user-group: <true/false> | 94 | no_user_group: <true/false> |
49 | 95 | passwd: <password> | 95 | passwd: <password> |
52 | 96 | primary-group: <primary group> | 96 | primary_group: <primary group> |
53 | 97 | selinux-user: <selinux username> | 97 | selinux_user: <selinux username> |
54 | 98 | shell: <shell path> | 98 | shell: <shell path> |
55 | 99 | snapuser: <email> | 99 | snapuser: <email> |
57 | 100 | ssh-authorized-keys: | 100 | ssh_authorized_keys: |
58 | 101 | - <key> | 101 | - <key> |
59 | 102 | - <key> | 102 | - <key> |
61 | 103 | ssh-import-id: <id> | 103 | ssh_import_id: <id> |
62 | 104 | sudo: <sudo config> | 104 | sudo: <sudo config> |
63 | 105 | system: <true/false> | 105 | system: <true/false> |
64 | 106 | uid: <user id> | 106 | uid: <user id> |
65 | diff --git a/doc/examples/cloud-config-user-groups.txt b/doc/examples/cloud-config-user-groups.txt | |||
66 | index 0554d1f..7bca24a 100644 | |||
67 | --- a/doc/examples/cloud-config-user-groups.txt | |||
68 | +++ b/doc/examples/cloud-config-user-groups.txt | |||
69 | @@ -10,20 +10,20 @@ users: | |||
70 | 10 | - default | 10 | - default |
71 | 11 | - name: foobar | 11 | - name: foobar |
72 | 12 | gecos: Foo B. Bar | 12 | gecos: Foo B. Bar |
74 | 13 | primary-group: foobar | 13 | primary_group: foobar |
75 | 14 | groups: users | 14 | groups: users |
77 | 15 | selinux-user: staff_u | 15 | selinux_user: staff_u |
78 | 16 | expiredate: 2012-09-01 | 16 | expiredate: 2012-09-01 |
80 | 17 | ssh-import-id: foobar | 17 | ssh_import_id: foobar |
81 | 18 | lock_passwd: false | 18 | lock_passwd: false |
82 | 19 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ | 19 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ |
83 | 20 | - name: barfoo | 20 | - name: barfoo |
84 | 21 | gecos: Bar B. Foo | 21 | gecos: Bar B. Foo |
85 | 22 | sudo: ALL=(ALL) NOPASSWD:ALL | 22 | sudo: ALL=(ALL) NOPASSWD:ALL |
86 | 23 | groups: users, admin | 23 | groups: users, admin |
88 | 24 | ssh-import-id: None | 24 | ssh_import_id: None |
89 | 25 | lock_passwd: true | 25 | lock_passwd: true |
91 | 26 | ssh-authorized-keys: | 26 | ssh_authorized_keys: |
92 | 27 | - <ssh pub key 1> | 27 | - <ssh pub key 1> |
93 | 28 | - <ssh pub key 2> | 28 | - <ssh pub key 2> |
94 | 29 | - name: cloudy | 29 | - name: cloudy |
95 | @@ -37,10 +37,10 @@ users: | |||
96 | 37 | # gecos: The user name's real name, i.e. "Bob B. Smith" | 37 | # gecos: The user name's real name, i.e. "Bob B. Smith" |
97 | 38 | # homedir: Optional. Set to the local path you want to use. Defaults to | 38 | # homedir: Optional. Set to the local path you want to use. Defaults to |
98 | 39 | # /home/<username> | 39 | # /home/<username> |
100 | 40 | # primary-group: define the primary group. Defaults to a new group created | 40 | # primary_group: define the primary group. Defaults to a new group created |
101 | 41 | # named after the user. | 41 | # named after the user. |
102 | 42 | # groups: Optional. Additional groups to add the user to. Defaults to none | 42 | # groups: Optional. Additional groups to add the user to. Defaults to none |
104 | 43 | # selinux-user: Optional. The SELinux user for the user's login, such as | 43 | # selinux_user: Optional. The SELinux user for the user's login, such as |
105 | 44 | # "staff_u". When this is omitted the system will select the default | 44 | # "staff_u". When this is omitted the system will select the default |
106 | 45 | # SELinux user. | 45 | # SELinux user. |
107 | 46 | # lock_passwd: Defaults to true. Lock the password to disable password login | 46 | # lock_passwd: Defaults to true. Lock the password to disable password login |
108 | @@ -66,11 +66,11 @@ users: | |||
109 | 66 | # should use SSH authentication only. | 66 | # should use SSH authentication only. |
110 | 67 | # | 67 | # |
111 | 68 | # You have thus been warned. | 68 | # You have thus been warned. |
117 | 69 | # no-create-home: When set to true, do not create home directory. | 69 | # no_create_home: When set to true, do not create home directory. |
118 | 70 | # no-user-group: When set to true, do not create a group named after the user. | 70 | # no_user_group: When set to true, do not create a group named after the user. |
119 | 71 | # no-log-init: When set to true, do not initialize lastlog and faillog database. | 71 | # no_log_init: When set to true, do not initialize lastlog and faillog database. |
120 | 72 | # ssh-import-id: Optional. Import SSH ids | 72 | # ssh_import_id: Optional. Import SSH ids |
121 | 73 | # ssh-authorized-keys: Optional. [list] Add keys to user's authorized keys file | 73 | # ssh_authorized_keys: Optional. [list] Add keys to user's authorized keys file |
122 | 74 | # sudo: Defaults to none. Set to the sudo string you want to use, i.e. | 74 | # sudo: Defaults to none. Set to the sudo string you want to use, i.e. |
123 | 75 | # ALL=(ALL) NOPASSWD:ALL. To add multiple rules, use the following | 75 | # ALL=(ALL) NOPASSWD:ALL. To add multiple rules, use the following |
124 | 76 | # format. | 76 | # format. |
125 | diff --git a/tests/cloud_tests/testcases/examples/including_user_groups.yaml b/tests/cloud_tests/testcases/examples/including_user_groups.yaml | |||
126 | index 469d03c..77528d9 100644 | |||
127 | --- a/tests/cloud_tests/testcases/examples/including_user_groups.yaml | |||
128 | +++ b/tests/cloud_tests/testcases/examples/including_user_groups.yaml | |||
129 | @@ -16,7 +16,7 @@ cloud_config: | | |||
130 | 16 | - default | 16 | - default |
131 | 17 | - name: foobar | 17 | - name: foobar |
132 | 18 | gecos: Foo B. Bar | 18 | gecos: Foo B. Bar |
134 | 19 | primary-group: foobar | 19 | primary_group: foobar |
135 | 20 | groups: users | 20 | groups: users |
136 | 21 | expiredate: 2038-01-19 | 21 | expiredate: 2038-01-19 |
137 | 22 | lock_passwd: false | 22 | lock_passwd: false |
138 | diff --git a/tests/cloud_tests/testcases/modules/user_groups.yaml b/tests/cloud_tests/testcases/modules/user_groups.yaml | |||
139 | index 22b5d70..675dfb8 100644 | |||
140 | --- a/tests/cloud_tests/testcases/modules/user_groups.yaml | |||
141 | +++ b/tests/cloud_tests/testcases/modules/user_groups.yaml | |||
142 | @@ -15,7 +15,7 @@ cloud_config: | | |||
143 | 15 | - default | 15 | - default |
144 | 16 | - name: foobar | 16 | - name: foobar |
145 | 17 | gecos: Foo B. Bar | 17 | gecos: Foo B. Bar |
147 | 18 | primary-group: foobar | 18 | primary_group: foobar |
148 | 19 | groups: users | 19 | groups: users |
149 | 20 | expiredate: 2038-01-19 | 20 | expiredate: 2038-01-19 |
150 | 21 | lock_passwd: false | 21 | lock_passwd: false |
151 | diff --git a/tests/data/merge_sources/expected7.yaml b/tests/data/merge_sources/expected7.yaml | |||
152 | index 25284f0..d32988e 100644 | |||
153 | --- a/tests/data/merge_sources/expected7.yaml | |||
154 | +++ b/tests/data/merge_sources/expected7.yaml | |||
155 | @@ -4,20 +4,20 @@ users: | |||
156 | 4 | - default | 4 | - default |
157 | 5 | - name: foobar | 5 | - name: foobar |
158 | 6 | gecos: Foo B. Bar | 6 | gecos: Foo B. Bar |
160 | 7 | primary-group: foobar | 7 | primary_group: foobar |
161 | 8 | groups: users | 8 | groups: users |
163 | 9 | selinux-user: staff_u | 9 | selinux_user: staff_u |
164 | 10 | expiredate: 2012-09-01 | 10 | expiredate: 2012-09-01 |
166 | 11 | ssh-import-id: foobar | 11 | ssh_import_id: foobar |
167 | 12 | lock-passwd: false | 12 | lock-passwd: false |
168 | 13 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ | 13 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ |
169 | 14 | - name: barfoo | 14 | - name: barfoo |
170 | 15 | gecos: Bar B. Foo | 15 | gecos: Bar B. Foo |
171 | 16 | sudo: ALL=(ALL) NOPASSWD:ALL | 16 | sudo: ALL=(ALL) NOPASSWD:ALL |
172 | 17 | groups: users, admin | 17 | groups: users, admin |
174 | 18 | ssh-import-id: None | 18 | ssh_import_id: None |
175 | 19 | lock-passwd: true | 19 | lock-passwd: true |
177 | 20 | ssh-authorized-keys: | 20 | ssh_authorized_keys: |
178 | 21 | - <ssh pub key 1> | 21 | - <ssh pub key 1> |
179 | 22 | - <ssh pub key 2> | 22 | - <ssh pub key 2> |
180 | 23 | - name: cloudy | 23 | - name: cloudy |
181 | @@ -29,10 +29,10 @@ users: | |||
182 | 29 | - sue | 29 | - sue |
183 | 30 | - name: foobar_jr | 30 | - name: foobar_jr |
184 | 31 | gecos: Foo B. Bar Jr | 31 | gecos: Foo B. Bar Jr |
186 | 32 | primary-group: foobar | 32 | primary_group: foobar |
187 | 33 | groups: users | 33 | groups: users |
189 | 34 | selinux-user: staff_u | 34 | selinux_user: staff_u |
190 | 35 | expiredate: 2012-09-01 | 35 | expiredate: 2012-09-01 |
192 | 36 | ssh-import-id: foobar | 36 | ssh_import_id: foobar |
193 | 37 | lock-passwd: false | 37 | lock-passwd: false |
194 | 38 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ | 38 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ |
195 | diff --git a/tests/data/merge_sources/source7-1.yaml b/tests/data/merge_sources/source7-1.yaml | |||
196 | index 8fb9b32..6405fc9 100644 | |||
197 | --- a/tests/data/merge_sources/source7-1.yaml | |||
198 | +++ b/tests/data/merge_sources/source7-1.yaml | |||
199 | @@ -4,20 +4,20 @@ users: | |||
200 | 4 | - default | 4 | - default |
201 | 5 | - name: foobar | 5 | - name: foobar |
202 | 6 | gecos: Foo B. Bar | 6 | gecos: Foo B. Bar |
204 | 7 | primary-group: foobar | 7 | primary_group: foobar |
205 | 8 | groups: users | 8 | groups: users |
207 | 9 | selinux-user: staff_u | 9 | selinux_user: staff_u |
208 | 10 | expiredate: 2012-09-01 | 10 | expiredate: 2012-09-01 |
210 | 11 | ssh-import-id: foobar | 11 | ssh_import_id: foobar |
211 | 12 | lock-passwd: false | 12 | lock-passwd: false |
212 | 13 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ | 13 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ |
213 | 14 | - name: barfoo | 14 | - name: barfoo |
214 | 15 | gecos: Bar B. Foo | 15 | gecos: Bar B. Foo |
215 | 16 | sudo: ALL=(ALL) NOPASSWD:ALL | 16 | sudo: ALL=(ALL) NOPASSWD:ALL |
216 | 17 | groups: users, admin | 17 | groups: users, admin |
218 | 18 | ssh-import-id: None | 18 | ssh_import_id: None |
219 | 19 | lock-passwd: true | 19 | lock-passwd: true |
221 | 20 | ssh-authorized-keys: | 20 | ssh_authorized_keys: |
222 | 21 | - <ssh pub key 1> | 21 | - <ssh pub key 1> |
223 | 22 | - <ssh pub key 2> | 22 | - <ssh pub key 2> |
224 | 23 | - name: cloudy | 23 | - name: cloudy |
225 | diff --git a/tests/data/merge_sources/source7-2.yaml b/tests/data/merge_sources/source7-2.yaml | |||
226 | index 1e26201..0cd2897 100644 | |||
227 | --- a/tests/data/merge_sources/source7-2.yaml | |||
228 | +++ b/tests/data/merge_sources/source7-2.yaml | |||
229 | @@ -6,11 +6,11 @@ users: | |||
230 | 6 | - sue | 6 | - sue |
231 | 7 | - name: foobar_jr | 7 | - name: foobar_jr |
232 | 8 | gecos: Foo B. Bar Jr | 8 | gecos: Foo B. Bar Jr |
234 | 9 | primary-group: foobar | 9 | primary_group: foobar |
235 | 10 | groups: users | 10 | groups: users |
237 | 11 | selinux-user: staff_u | 11 | selinux_user: staff_u |
238 | 12 | expiredate: 2012-09-01 | 12 | expiredate: 2012-09-01 |
240 | 13 | ssh-import-id: foobar | 13 | ssh_import_id: foobar |
241 | 14 | lock-passwd: false | 14 | lock-passwd: false |
242 | 15 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ | 15 | passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ |
243 | 16 | 16 |
this one is harder than it should be.
_normalize_users ends up fixing the '-' to '_' in all those before create_ user' gets called. So either actually works.
'distro.
Documentation and implementation in cloud-init have unfortunately been
inconsistent with '-' versus '_'.
We should absolutely strive to be consistent both in implementation
and in documentation.
So... authorized- keys' support either - or _. Lets just change everything to config/ cc_users_ groups. py to match (that is what ends up cloudinit. readthedocs. io/en/latest/ topics/ modules. html#users- and-groups
* I'm 98% certain that 'ssh-import-id' in the diff context and
'ssh-
document '_' for consistency.
Please fix those also.
* lets also update the in-module documentation in
cloudinit/
being documented at
http://