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

subversion module: fail on https checkout #36498

Closed
miniwark opened this issue Feb 21, 2018 · 9 comments · Fixed by #74405
Closed

subversion module: fail on https checkout #36498

miniwark opened this issue Feb 21, 2018 · 9 comments · Fixed by #74405
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation source_control Source-control category support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. verified This issue has been verified/reproduced by maintainer

Comments

@miniwark
Copy link

miniwark commented Feb 21, 2018

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible_module_subversion

ANSIBLE VERSION
2.4.3.0
CONFIGURATION
DEFAULT_ASK_PASS(/home/moss/Documents/Developpement/Ansible-playbooks/ansible.cfg) = True
DEFAULT_HOST_LIST(/home/moss/Documents/Developpement/Ansible-playbooks/ansible.cfg) = [u'/home/moss/Documents/Developpement/Ansible-playbooks/hosts']
OS / ENVIRONMENT
  • From: Ubuntu 16.04
  • Manage: Debian 9.2
  • Subversion version on manage: 1.9.5 (r1770682)
SUMMARY

The subversion module fail with error "'NoneType' object has no attribute 'group'"

STEPS TO REPRODUCE

With this task:

- name: Svn checkout of /usr/local/sbin/scripts
  subversion:
    repo: https://forge.reynholm-industries.co.uk/path/torepo/directory/trunk/scripts
    dest: /usr/local/sbin/script-cocktail
    username: "mauricemoss"
    password: "<redacted>"

(the top repo is forge.reynholm-industries.co.uk/path/torepo )

EXPECTED RESULTS

The repo is being checkout and Ansible give a green light

ACTUAL RESULTS

The checkout is done correctly on the managed host
but Ansible fail with:

Using module file /usr/lib/python2.7/dist-packages/ansible/modules/source_control/subversion.py
<moss.reynholm-industries.co.uk> ESTABLISH SSH CONNECTION FOR USER: None
<moss.reynholm-industries.co.uk> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/home/moss/.ansible/cp/493c6155b5 moss.reynholm-industries.co.uk '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<moss.reynholm-industries.co.uk> (0, '/home/moss\n', '')
<moss.reynholm-industries.co.uk> ESTABLISH SSH CONNECTION FOR USER: None
<moss.reynholm-industries.co.uk> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/home/moss/.ansible/cp/493c6155b5 moss.reynholm-industries.co.uk '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325 `" && echo ansible-tmp-1519208327.22-164280939884325="` echo /home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325 `" ) && sleep 0'"'"''
<moss.reynholm-industries.co.uk> (0, 'ansible-tmp-1519208327.22-164280939884325=/home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325\n', '')
<moss.reynholm-industries.co.uk> PUT /tmp/tmpmHJkjm TO /home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325/subversion.py
<moss.reynholm-industries.co.uk> SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/home/moss/.ansible/cp/493c6155b5 '[dsi1app.oca.eu]'
<moss.reynholm-industries.co.uk> (0, 'sftp> put /tmp/tmpmHJkjm /home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325/subversion.py\n', '')
<moss.reynholm-industries.co.uk> ESTABLISH SSH CONNECTION FOR USER: None
<moss.reynholm-industries.co.uk> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/home/moss/.ansible/cp/493c6155b5 moss.reynholm-industries.co.uk '/bin/sh -c '"'"'chmod u+x /home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325/ /home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325/subversion.py && sleep 0'"'"''
<moss.reynholm-industries.co.uk> (0, '', '')
<moss.reynholm-industries.co.uk> ESTABLISH SSH CONNECTION FOR USER: None
<moss.reynholm-industries.co.uk> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/home/moss/.ansible/cp/493c6155b5 -tt moss.reynholm-industries.co.uk '/bin/sh -c '"'"'sudo -H -S  -p "[sudo via ansible, key=drrkxyafylgyufhguivcrimzobxvmthb] password: " -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-drrkxyafylgyufhguivcrimzobxvmthb; /usr/bin/python /home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325/subversion.py; rm -rf "/home/moss/.ansible/tmp/ansible-tmp-1519208327.22-164280939884325/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
<moss.reynholm-industries.co.uk> (0, '\r\nTraceback (most recent call last):\r\n  File "/tmp/ansible_FqZ4hU/ansible_module_subversion.py", line 306, in <module>\r\n    main()\r\n  File "/tmp/ansible_FqZ4hU/ansible_module_subversion.py", line 284, in main\r\n    before = svn.get_revision()\r\n  File "/tmp/ansible_FqZ4hU/ansible_module_subversion.py", line 190, in get_revision\r\n    rev = re.search(r\'^Revision:.*$\', text, re.MULTILINE).group(0)\r\nAttributeError: \'NoneType\' object has no attribute \'group\'\r\n', 'Shared connection to moss.reynholm-industries.co.uk closed.\r\n')
fatal: [moss.reynholm-industries.co.uk]: FAILED! => {
    "changed": false, 
    "module_stderr": "Shared connection to moss.reynholm-industries.co.uk closed.\r\n", 
    "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_FqZ4hU/ansible_module_subversion.py\", line 306, in <module>\r\n    main()\r\n  File \"/tmp/ansible_FqZ4hU/ansible_module_subversion.py\", line 284, in main\r\n    before = svn.get_revision()\r\n  File \"/tmp/ansible_FqZ4hU/ansible_module_subversion.py\", line 190, in get_revision\r\n    rev = re.search(r'^Revision:.*$', text, re.MULTILINE).group(0)\r\nAttributeError: 'NoneType' object has no attribute 'group'\r\n", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

Hi highly suspect a similar problem to issue #3255 because the managed host have French as default language.

By the way the svn result from command line is:

> /usr/bin/svn --non-interactive --trust-server-cert --no-auth-cache --username mauricemoss --password '<redacted>' checkout -r HEAD https://forge.reynholm-industries.co.uk/path/torepo/directory/trunk/scripts /usr/local/sbin/scripts
> Révision 14332 extraite.
@ansibot
Copy link
Contributor

ansibot commented Feb 21, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Feb 21, 2018

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Feb 21, 2018
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Feb 23, 2018
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@ansibot ansibot added the traceback This issue/PR includes a traceback. label May 26, 2018
@ansibot ansibot added the source_control Source-control category label Feb 17, 2019
@ansibot
Copy link
Contributor

ansibot commented May 16, 2020

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@bcoca bcoca added needs_verified This issue needs to be verified/reproduced by maintainer P3 Priority 3 - Approved, No Time Limitation labels Apr 23, 2021
@samdoran
Copy link
Contributor

The command being run is essentially svn info [repo], the output of which is affected by LC_* variables. I can duplicate this failure by setting LC_ALL=es_ES.UTF-8. The output the becomes:

Ruta: /tmp/xml-crimson
Working Copy Root Path: /tmp/xml-crimson
URL: http://svn.apache.org/repos/asf/xml/crimson/trunk
Relative URL: ^/xml/crimson/trunk
Raíz del repositorio: http://svn.apache.org/repos/asf
UUID del repositorio: 13f79535-47bb-0310-9956-ffa450edef68
Revisión: 1889132
Tipo de nodo: directorio
Agendado: normal
Autor del último cambio: edwingo
Revisión del último cambio: 313192
Fecha de último cambio: 2002-04-22 20:09:22 -0400 (lun 22 de abr de 2002)

The regexp that is parsing this output is '^Revision:.*$' which will not match anything. This results in a None object, which has no group() attribute.

That regular expression is used in several places in the module.

@samdoran samdoran added verified This issue has been verified/reproduced by maintainer and removed needs_verified This issue needs to be verified/reproduced by maintainer labels Apr 23, 2021
@bcoca
Copy link
Member

bcoca commented Apr 23, 2021

always need to force 'C' locale when scraping ....

@samdoran
Copy link
Contributor

Yup. I was just looking at doing that. 😁

@samdoran
Copy link
Contributor

The solution is we need to explicitly set the locale in the module. I'll put together a PR.

@samdoran
Copy link
Contributor

Turns out we already set this, just not completely. LC_ALL needs to be set as well.

module.run_command_environ_update = dict(LANG='C', LC_MESSAGES='C')

@samdoran
Copy link
Contributor

samdoran commented Apr 23, 2021

Wow, there's a lot of history here.

ansible/ansible-modules-core#3257 - added dict(LANG='C', LC_ALL='C', LC_MESSAGES='C', LC_CTYPE='C') which broke paths with non-ASCII characters.

ansible/ansible-modules-core#4358 - partially reverted the above change, which is how the code is today.

Setting LC_ALL='C' like I was thinking breaks paths with non-ASCII characters in the path. 🤦

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation source_control Source-control category support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants