Greetings,

Attempting to understand why this difference exists installing a
package on OpenBSD 6.0 using the more general 'package' module vs. the
underlying installer module 'openbsd_pkg'. The package is given in
format supported for recent version of OpenBSD's package tools where
the branch can be specified using a '%' as the delimiter after package
name, hence below I use 'php%5.6' to install the PHP 5.6 branch from
package repo.

OS: OpenBSD 6.0 amd64
Python: 2.7.12 cpython
Ansible: 2.2.0.0


Value of variable used in tasks:

php_ver: "5.6"

Failure case task:

- name: install php
  package:
    name: "{{ item }}"
    state: present
  with_items:
    - "php%{{ php_ver }}"
  tags: [httpd, web_stack, php]

Result:

TASK [openbsd_httpd : install php]
*********************************************

                         [119/309]
task path: /etc/ansible/roles/openbsd_httpd/tasks/php.yml:3
Using module file
/usr/local/lib/python2.7/site-packages/ansible/modules/extras/packaging/os/openbsd_pkg.py
<molodetz> ESTABLISH LOCAL CONNECTION FOR USER: dspruell
<molodetz> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
$HOME/.ansible/tmp/ansible-tmp-1483740555.18-20269133733439 `" && echo
ansible-tmp-1483740555.18-20269133733439="` echo
$HOME/.ansible/tmp/ansible-tmp-1
483740555.18-20269133733439 `" ) && sleep 0'
<molodetz> PUT /tmp/tmpKt3WwN TO
/home/dspruell/.ansible/tmp/ansible-tmp-1483740555.18-20269133733439/openbsd_pkg.py
<molodetz> EXEC /bin/sh -c 'chmod u+x
/home/dspruell/.ansible/tmp/ansible-tmp-1483740555.18-20269133733439/
/home/dspruell/.ansible/tmp/ansible-tmp-1483740555.18-20269133733439/openbsd_pkg.py
&& sleep 0'
<molodetz> EXEC /bin/sh -c 'doas  -n  -u root  echo
BECOME-SUCCESS-vuyrqbdqyzccnaxpataiauojdpsybnuw && doas  -n  -u root
env ANSIBLE=true /usr/local/bin/python
/home/dspruell/.ansible/tmp/ansible-tmp-1483740555
.18-20269133733439/openbsd_pkg.py; rm -rf
"/home/dspruell/.ansible/tmp/ansible-tmp-1483740555.18-20269133733439/"
> /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_gFhctJ/ansible_module_openbsd_pkg.py", line 529,
in <module>
    main()
  File "/tmp/ansible_gFhctJ/ansible_module_openbsd_pkg.py", line 511, in main
    (rc, stdout, stderr, changed) = package_present(name,
installed_state, pkg_spec, module)
  File "/tmp/ansible_gFhctJ/ansible_module_openbsd_pkg.py", line 180,
in package_present
    match = re.search("\W%s-[^:]+: ok\W" % pkg_spec['pkgname'], stdout)
  File "/usr/local/lib/python2.7/re.py", line 146, in search
    return _compile(pattern, flags).search(string)
  File "/usr/local/lib/python2.7/re.py", line 251, in _compile
    raise error, v # invalid expression
sre_constants.error: bad character range

failed: [molodetz] (item=[u'php%5.6']) => {
    "failed": true,
    "invocation": {
        "module_args": {
            "name": [
                "php%5.6"
            ],
            "state": "present"
        },
        "module_name": "package"
    },
    "item": [
        "php%5.6"
    ],
    "module_stderr": "Traceback (most recent call last):\n  File
\"/tmp/ansible_gFhctJ/ansible_module_openbsd_pkg.py\", line 529, in
<module>\n    main()\n  File
\"/tmp/ansible_gFhctJ/ansible_module_openbsd_pkg$
py\", line 511, in main\n    (rc, stdout, stderr, changed) =
package_present(name, installed_state, pkg_spec, module)\n  File
\"/tmp/ansible_gFhctJ/ansible_module_openbsd_pkg.py\", line 180, in
package_present\$
    match = re.search(\"\\W%s-[^:]+: ok\\W\" % pkg_spec['pkgname'],
stdout)\n  File \"/usr/local/lib/python2.7/re.py\", line 146, in
search\n    return _compile(pattern, flags).search(string)\n  File
\"/usr/loc$
l/lib/python2.7/re.py\", line 251, in _compile\n    raise error, v #
invalid expression\nsre_constants.error: bad character range\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE"
}


Success case task:

- name: install php
  openbsd_pkg:
    name: "{{ item }}"
    state: present
  with_items:
    - "php%{{ php_ver }}"
  tags: [httpd, web_stack, php]

Result:

TASK [openbsd_httpd : install php] *********************************************
task path: /etc/ansible/roles/openbsd_httpd/tasks/php.yml:10
Using module file
/usr/local/lib/python2.7/site-packages/ansible/modules/extras/packaging/os/openbsd_pkg.py
<molodetz> ESTABLISH LOCAL CONNECTION FOR USER: dspruell
<molodetz> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
$HOME/.ansible/tmp/ansible-tmp-1483740920.56-228683905932090 `" &&
echo ansible-tmp-1483740920.56-228683905932090="` echo
$HOME/.ansible/tmp/ansible-tmp-1483740920.56-228683905932090 `" ) &&
sleep 0'
<molodetz> PUT /tmp/tmpC7ojNJ TO
/home/dspruell/.ansible/tmp/ansible-tmp-1483740920.56-228683905932090/openbsd_pkg.py
<molodetz> EXEC /bin/sh -c 'chmod u+x
/home/dspruell/.ansible/tmp/ansible-tmp-1483740920.56-228683905932090/
/home/dspruell/.ansible/tmp/ansible-tmp-1483740920.56-228683905932090/openbsd_pkg.py
&& sleep 0'
<molodetz> EXEC /bin/sh -c 'doas  -n  -u root  echo
BECOME-SUCCESS-kvaawdyqduryzxrfqymiuyjlxckasuuy && doas  -n  -u root
env ANSIBLE=true /usr/local/bin/python
/home/dspruell/.ansible/tmp/ansible-tmp-1483740920.56-228683905932090/openbsd_pkg.py;
rm -rf "/home/dspruell/.ansible/tmp/ansible-tmp-1483740920.56-228683905932090/"
> /dev/null 2>&1 && sleep 0'
changed: [molodetz] => (item=php%5.6) => {
    "build": false,
    "changed": true,
    "invocation": {
        "module_args": {
            "build": false,
            "name": "php%5.6",
            "ports_dir": "/usr/ports",
            "state": "present"
        },
        "module_name": "openbsd_pkg"
    },
    "item": "php%5.6",
    "name": "php%5.6",
    "state": "present"
}


I understand from documentation on the 'package' module that it calls
the underlying OS package module anyway (can see openbsd_pkg.py in
output above) so curious why this fails when using the 'package'
module in the task?

-- 
Darren Spruell
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKVSOJUv%2B5TXPROKXEzZpJCEmYOT6gCo8JTfAsU97wqa7mnxcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to