Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-22 Thread Daniel Jakots
On Tue, 18 Oct 2016 20:13:27 +0200, Jasper Lievisse Adriaanse
 wrote:

> So this diff below is a sync with upstream devel as of right now

Please go ahead, it unbreaks ansible. ok danj@

Cheers,
Daniel



Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-18 Thread Jasper Lievisse Adriaanse
On Tue, Oct 18, 2016 at 07:58:00AM +0200, Patrik Lundin wrote:
> On Tue, Oct 18, 2016 at 06:30:41AM +0200, Jasper Lievisse Adriaanse wrote:
> >
> > I was hoping that 2.2.0.0 would be released soon, but it seems upstream 
> > enjoys
> > many a rc over a lengthy period of time. So perhaps syncing the openbsd_pkg
> > provider with master would be the way to go.
> > 
> 
> This would be my personal preference. This also means the local addition
> of -z comes into question as the upstream changes replace "pkg_info -e"
> with "pkg_info -Iq" for looking up package state, which does not handle
> name lookups in the same way.
> 
> I believe landry@ should be involved in this decision because from what I
> recall he is one of the people who wanted the addition (and might be depending
> on it).
> 
> I'll repeat my original thoughts about this from when I added the branch
> support:
> ===
> I should add that I think the -z addition may actually work worse on the
> latest code, because i switched the usage of "pkg_info -e" to "pkg_info
> -Iq inst:name" for finding out the state of a requested package. While
> -e manages to find a package without the patchlevel version attached
> (which i believe was a benefit that -z added), this does not
> seem to be true for "-Iq inst:".
> 
> This could mean that the module will always think that the package
> needs to be installed because it can't tell there is a package with the
> supplied name (plus patchlevel) already installed.
> ===
> 
> -- 
> Patrik Lundin
I think part of the reason why -z was added was precisely to "workaround" the
problem that was resolved with the support for branch notation. So this diff
below is a sync with upstream devel as of right now, which is due to be
released as part of ansible 2.2.0.0, and thus drops our local -z patch.

Index: Makefile
===
RCS file: /cvs/ports/sysutils/ansible/Makefile,v
retrieving revision 1.62
diff -u -p -r1.62 Makefile
--- Makefile15 Oct 2016 09:04:36 -  1.62
+++ Makefile18 Oct 2016 18:11:05 -
@@ -4,7 +4,7 @@ COMMENT =   ssh based config management f
 
 MODPY_EGG_VERSION =2.1.2.0
 DISTNAME = ansible-${MODPY_EGG_VERSION}
-REVISION = 3
+REVISION = 4
 
 CATEGORIES =   sysutils
 
Index: patches/patch-lib_ansible_modules_extras_packaging_os_openbsd_pkg_py
===
RCS file: 
/cvs/ports/sysutils/ansible/patches/patch-lib_ansible_modules_extras_packaging_os_openbsd_pkg_py,v
retrieving revision 1.5
diff -u -p -r1.5 patch-lib_ansible_modules_extras_packaging_os_openbsd_pkg_py
--- patches/patch-lib_ansible_modules_extras_packaging_os_openbsd_pkg_py
15 Oct 2016 08:33:52 -  1.5
+++ patches/patch-lib_ansible_modules_extras_packaging_os_openbsd_pkg_py
18 Oct 2016 18:11:05 -
@@ -1,32 +1,107 @@
 $OpenBSD: patch-lib_ansible_modules_extras_packaging_os_openbsd_pkg_py,v 1.5 
2016/10/15 08:33:52 jasper Exp $
 
-Hunks 3+4:
-From 2001172027e339037adaa290e77a7700c818ad57 Mon Sep 17 00:00:00 2001
-From: Patrik Lundin 
-Date: Wed, 12 Oct 2016 20:51:22 +0200
-Subject: [PATCH 1/2] openbsd_pkg: Use correct part of name in match.
+sync with upstream revision 16b8128
 
 lib/ansible/modules/extras/packaging/os/openbsd_pkg.py.origFri Oct 
14 14:30:50 2016
-+++ lib/ansible/modules/extras/packaging/os/openbsd_pkg.py Fri Oct 14 
14:30:40 2016
-@@ -144,7 +144,7 @@ def package_present(name, installed_state, pkg_spec, m
- build = module.params['build']
- 
- if module.check_mode:
--install_cmd = 'pkg_add -Imn'
-+install_cmd = 'pkg_add -Imnz'
- else:
- if build is True:
- port_dir = "%s/%s" % (module.params['ports_dir'], 
get_package_source_path(name, pkg_spec, module))
-@@ -159,7 +159,7 @@ def package_present(name, installed_state, pkg_spec, m
- else:
- module.fail_json(msg="the port source directory %s does not 
exist" % (port_dir))
- else:
--install_cmd = 'pkg_add -Im'
-+install_cmd = 'pkg_add -Imz'
+--- lib/ansible/modules/extras/packaging/os/openbsd_pkg.py.origThu Sep 
29 17:01:33 2016
 lib/ansible/modules/extras/packaging/os/openbsd_pkg.py Tue Oct 18 
20:09:30 2016
+@@ -19,10 +19,13 @@
+ # along with Ansible.  If not, see .
+ 
+ import os
++import platform
+ import re
+ import shlex
+ import sqlite3
+ 
++from distutils.version import StrictVersion
++
+ DOCUMENTATION = '''
+ ---
+ module: openbsd_pkg
+@@ -82,6 +85,9 @@ EXAMPLES = '''
+ # Specify the default flavour to avoid ambiguity errors
+ - openbsd_pkg: name=vim-- state=present
+ 
++# Specify a package branch (requires at least OpenBSD 6.0)
++- openbsd_pkg: name=python%3.5 state=present
++
+ # Update all packages on the system
+ - openbsd_pkg: name=* state=latest
+ '''
+@@ -94,47 +100,22 @@ def execute_command(cmd,

Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-18 Thread Patrik Lundin
On Tue, Oct 18, 2016 at 09:19:22AM +0200, Landry Breuil wrote:
> 
> So the original idea was more or less to use -z to 'fake' branch
> support when it wasnt existing.
> 

Maby this is a good time to retire the local patch if the branch syntax
solves those problems for newer systems?

> As for pkg_info -e vs pkg_info -Iq, i dont know what was the intent of
> the change nor if it was good or not
>

The reason for the change was to make the branch syntax work. -Iq
inst: can expand a name based on the branch syntax to the actual
installed version, which -e can not do:
===
$ pkg_info -e autoconf%2.13
Invalid spec: autoconf%2.13

$ pkg_info -Iq inst:autoconf%2.13
autoconf-2.13p4
===

>
> but here -Iq finds an installed
> package by giving only its name (but not if you pass the version without
> patchlevel):
> 
> $pkg_info -Iq ansible
> ansible-2.1.1.0p2
> $pkg_info -e ansible
> Invalid spec: ansible
> $pkg_info -e ansible-2.1.1.0
> inst:ansible-2.1.1.0p2
> $pkg_info -Dunsigned -Iq ansible-2.1.1.0
> Error from 
> http://ftp.fr.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/ansible-2.1.1.0.tgz
> ftp: Error retrieving file: 404 Not Found
> $pkg_info -Iq ansible-2.1.1.0p2
> ansible-2.1.1.0p2
> 
> The only 'advantage' of -e here is that it finds it if you pass the full
> version without the patchlevel.
> 

Right, the reason for the switch was the requirement to find the real
package on disk when a user supplies a name using the branch syntax.

-- 
Patrik Lundin



Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-18 Thread Landry Breuil
On Tue, Oct 18, 2016 at 07:58:00AM +0200, Patrik Lundin wrote:
> On Tue, Oct 18, 2016 at 06:30:41AM +0200, Jasper Lievisse Adriaanse wrote:
> >
> > I was hoping that 2.2.0.0 would be released soon, but it seems upstream 
> > enjoys
> > many a rc over a lengthy period of time. So perhaps syncing the openbsd_pkg
> > provider with master would be the way to go.
> > 
> 
> This would be my personal preference. This also means the local addition
> of -z comes into question as the upstream changes replace "pkg_info -e"
> with "pkg_info -Iq" for looking up package state, which does not handle
> name lookups in the same way.
> 
> I believe landry@ should be involved in this decision because from what I
> recall he is one of the people who wanted the addition (and might be depending
> on it).

For full history:

http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/sysutils/ansible/patches/Attic/patch-library_packaging_openbsd_pkg
=
Use -z when invoking pkg_add in openbsd_pkg module, so that one can use
for example php-fpm-5.4* and ensure the correct version is installed.
Previously, one had to specify the exact version, or ansible would fail
since there were alternatives.
=
And the discussion with upstream in the maze of github tickets:
https://github.com/ansible/ansible/issues/8990
https://github.com/ansible/ansible-modules-extras/issues/97

So the original idea was more or less to use -z to 'fake' branch
support when it wasnt existing.

As for pkg_info -e vs pkg_info -Iq, i dont know what was the intent of
the change nor if it was good or not, but here -Iq finds an installed
package by giving only its name (but not if you pass the version without
patchlevel):

$pkg_info -Iq ansible
ansible-2.1.1.0p2
$pkg_info -e ansible
Invalid spec: ansible
$pkg_info -e ansible-2.1.1.0
inst:ansible-2.1.1.0p2
$pkg_info -Dunsigned -Iq ansible-2.1.1.0
Error from 
http://ftp.fr.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/ansible-2.1.1.0.tgz
ftp: Error retrieving file: 404 Not Found
$pkg_info -Iq ansible-2.1.1.0p2
ansible-2.1.1.0p2

The only 'advantage' of -e here is that it finds it if you pass the full
version without the patchlevel.

Landry



Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-17 Thread Patrik Lundin
On Tue, Oct 18, 2016 at 06:30:41AM +0200, Jasper Lievisse Adriaanse wrote:
>
> I was hoping that 2.2.0.0 would be released soon, but it seems upstream enjoys
> many a rc over a lengthy period of time. So perhaps syncing the openbsd_pkg
> provider with master would be the way to go.
> 

This would be my personal preference. This also means the local addition
of -z comes into question as the upstream changes replace "pkg_info -e"
with "pkg_info -Iq" for looking up package state, which does not handle
name lookups in the same way.

I believe landry@ should be involved in this decision because from what I
recall he is one of the people who wanted the addition (and might be depending
on it).

I'll repeat my original thoughts about this from when I added the branch
support:
===
I should add that I think the -z addition may actually work worse on the
latest code, because i switched the usage of "pkg_info -e" to "pkg_info
-Iq inst:name" for finding out the state of a requested package. While
-e manages to find a package without the patchlevel version attached
(which i believe was a benefit that -z added), this does not
seem to be true for "-Iq inst:".

This could mean that the module will always think that the package
needs to be installed because it can't tell there is a package with the
supplied name (plus patchlevel) already installed.
===

-- 
Patrik Lundin



Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-17 Thread Jasper Lievisse Adriaanse
On Mon, Oct 17, 2016 at 08:55:38PM +0200, Patrik Lundin wrote:
> On Mon, Oct 17, 2016 at 06:58:26PM +0200, Jasper Lievisse Adriaanse wrote:
> > On Mon, Oct 17, 2016 at 02:59:43PM +0200, Sebastien Marie wrote:
> > > Hi,
> > > 
> > > With the latest update of ansible (ansible-2.1.2.0->2.1.2.0p3), I
> > > experiment failure in the use of `openbsd_pkg' module.
> > > 
> > > The exception occurs when specifying a package name without version or
> > > branch (like juste "sysclean"). The code will assume branch syntax and
> > > will fail at extracting branch information after '%'.
> > > 
> > 
> > Does this also happen when you remove the two '-z' parts of the local patch 
> > we
> > carry for ansible? I don't have a CVS tree around right now to provide you 
> > with
> > a patch to apply.
> > 
> 
> Removing -z will not be enough. The openbsd_pkg.py file from the
> extracted tar ball is missing a lot of branch related changes from
> upstream.
> 
> This particular problem is a result of adding the last iteration of
> branch-syntax fixes without the previous plumbing.
> 
> Doing a diff -u between a "make extract" version of openbsd_pkg.py and
> an upstream version from git shows quite a bit of changes that are
> missing.
> 
> -- 
> Patrik Lundin
I was hoping that 2.2.0.0 would be released soon, but it seems upstream enjoys
many a rc over a lengthy period of time. So perhaps syncing the openbsd_pkg
provider with master would be the way to go. 

-- 
jasper



Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-17 Thread Patrik Lundin
On Mon, Oct 17, 2016 at 06:58:26PM +0200, Jasper Lievisse Adriaanse wrote:
> On Mon, Oct 17, 2016 at 02:59:43PM +0200, Sebastien Marie wrote:
> > Hi,
> > 
> > With the latest update of ansible (ansible-2.1.2.0->2.1.2.0p3), I
> > experiment failure in the use of `openbsd_pkg' module.
> > 
> > The exception occurs when specifying a package name without version or
> > branch (like juste "sysclean"). The code will assume branch syntax and
> > will fail at extracting branch information after '%'.
> > 
> 
> Does this also happen when you remove the two '-z' parts of the local patch we
> carry for ansible? I don't have a CVS tree around right now to provide you 
> with
> a patch to apply.
> 

Removing -z will not be enough. The openbsd_pkg.py file from the
extracted tar ball is missing a lot of branch related changes from
upstream.

This particular problem is a result of adding the last iteration of
branch-syntax fixes without the previous plumbing.

Doing a diff -u between a "make extract" version of openbsd_pkg.py and
an upstream version from git shows quite a bit of changes that are
missing.

-- 
Patrik Lundin



Re: ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-17 Thread Jasper Lievisse Adriaanse
On Mon, Oct 17, 2016 at 02:59:43PM +0200, Sebastien Marie wrote:
> Hi,
> 
> With the latest update of ansible (ansible-2.1.2.0->2.1.2.0p3), I
> experiment failure in the use of `openbsd_pkg' module.
> 
> The exception occurs when specifying a package name without version or
> branch (like juste "sysclean"). The code will assume branch syntax and
> will fail at extracting branch information after '%'.
> 
> As workaround it works with explicitly specifying the version-less name
> (like "sysclean--").
> 
> 
> $ doas ansible -vvv localhost -m openbsd_pkg -a 'name=sysclean state=present'
> Using /etc/ansible/ansible.cfg as config file
>  [WARNING]: provided hosts list is empty, only localhost is available
> 
> <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: semarie
> <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
> $HOME/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685 `" && echo 
> ansible-tmp-1476708883.67-184353742364685="` echo 
> $HOME/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685 `" ) && sleep 0'
> <127.0.0.1> PUT /tmp/tmp8ykgP0 TO 
> /home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/openbsd_pkg
> <127.0.0.1> EXEC /bin/sh -c 'chmod u+x 
> /home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/ 
> /home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/openbsd_pkg
>  && sleep 0'
> <127.0.0.1> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 
> LC_MESSAGES=en_US.UTF-8 /usr/local/bin/python2.7 
> /home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/openbsd_pkg;
>  rm -rf 
> "/home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/" > 
> /dev/null 2>&1 && sleep 0'
> An exception occurred during task execution. The full traceback is:
> Traceback (most recent call last):
>   File "/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py", line 512, in 
> 
> main()
>   File "/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py", line 487, in main
> parse_package_name(name, pkg_spec, module)
>   File "/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py", line 358, in 
> parse_package_name
> pkg_spec['branch'] = pkg_spec['stem'].split('%')[1]
> IndexError: list index out of range
> 
> localhost | FAILED! => {
> "changed": false, 
> "failed": true, 
> "invocation": {
> "module_name": "openbsd_pkg"
> }, 
> "module_stderr": "Traceback (most recent call last):\n  File 
> \"/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py\", line 512, in 
> \nmain()\n  File 
> \"/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py\", line 487, in main\n
> parse_package_name(name, pkg_spec, module)\n  File 
> \"/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py\", line 358, in 
> parse_package_name\npkg_spec['branch'] = 
> pkg_spec['stem'].split('%')[1]\nIndexError: list index out of range\n", 
> "module_stdout": "", 
> "msg": "MODULE FAILURE"
> }
> 
> -- 
> Sebastien Marie

Does this also happen when you remove the two '-z' parts of the local patch we
carry for ansible? I don't have a CVS tree around right now to provide you with
a patch to apply.

-- 
jasper



ansible: openbsd_pkg fails to run when just specifying the package name

2016-10-17 Thread Sebastien Marie
Hi,

With the latest update of ansible (ansible-2.1.2.0->2.1.2.0p3), I
experiment failure in the use of `openbsd_pkg' module.

The exception occurs when specifying a package name without version or
branch (like juste "sysclean"). The code will assume branch syntax and
will fail at extracting branch information after '%'.

As workaround it works with explicitly specifying the version-less name
(like "sysclean--").


$ doas ansible -vvv localhost -m openbsd_pkg -a 'name=sysclean state=present'
Using /etc/ansible/ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available

<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: semarie
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
$HOME/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685 `" && echo 
ansible-tmp-1476708883.67-184353742364685="` echo 
$HOME/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmp8ykgP0 TO 
/home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/openbsd_pkg
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x 
/home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/ 
/home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/openbsd_pkg
 && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8 /usr/local/bin/python2.7 
/home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/openbsd_pkg;
 rm -rf "/home/semarie/.ansible/tmp/ansible-tmp-1476708883.67-184353742364685/" 
> /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py", line 512, in 

main()
  File "/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py", line 487, in main
parse_package_name(name, pkg_spec, module)
  File "/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py", line 358, in 
parse_package_name
pkg_spec['branch'] = pkg_spec['stem'].split('%')[1]
IndexError: list index out of range

localhost | FAILED! => {
"changed": false, 
"failed": true, 
"invocation": {
"module_name": "openbsd_pkg"
}, 
"module_stderr": "Traceback (most recent call last):\n  File 
\"/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py\", line 512, in \n  
  main()\n  File \"/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py\", line 
487, in main\nparse_package_name(name, pkg_spec, module)\n  File 
\"/tmp/ansible_t2obkK/ansible_module_openbsd_pkg.py\", line 358, in 
parse_package_name\npkg_spec['branch'] = 
pkg_spec['stem'].split('%')[1]\nIndexError: list index out of range\n", 
"module_stdout": "", 
"msg": "MODULE FAILURE"
}

-- 
Sebastien Marie