mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Strip trailing comments from /etc/default/passwd (#43931)
* strip additional comments from /etc/default/passwd Strip trailling comments from /etc/default/passwd like MINWEEKS=1 #MINWEEKS=2 MAXWEEKS=12 # MAXWEEKS=8 Which otherwise cause failures with "failed to read /etc/default/passwd: too many values to unpack" * fix carriage return typo in commit * yet another typo in commit * Fix indent problem * add changelog fragment for PR 43931
This commit is contained in:
parent
3ddec4d64e
commit
5c1e620504
2 changed files with 6 additions and 0 deletions
2
changelogs/fragments/43931-strip-trailing-comments.yml
Normal file
2
changelogs/fragments/43931-strip-trailing-comments.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- user - Strip trailing comments in /etc/default/passwd (https://github.com/ansible/ansible/pull/43931)
|
|
@ -348,6 +348,7 @@ import pwd
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
from ansible.module_utils.basic import load_platform_subclass, AnsibleModule
|
from ansible.module_utils.basic import load_platform_subclass, AnsibleModule
|
||||||
|
@ -1525,6 +1526,9 @@ class SunOS(User):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if (line.startswith('#') or line == ''):
|
if (line.startswith('#') or line == ''):
|
||||||
continue
|
continue
|
||||||
|
m = re.match(r'^([^#]*)#(.*)$', line)
|
||||||
|
if m: # The line contains a hash / comment
|
||||||
|
line = m.group(1)
|
||||||
key, value = line.split('=')
|
key, value = line.split('=')
|
||||||
if key == "MINWEEKS":
|
if key == "MINWEEKS":
|
||||||
minweeks = value.rstrip('\n')
|
minweeks = value.rstrip('\n')
|
||||||
|
|
Loading…
Reference in a new issue