Bootstrapping FreeBSD with Ansible 2.0: RAW module does not work anymore?

171 views
Skip to first unread message

Johannes Kastl

unread,
Feb 10, 2016, 2:37:14 PM2/10/16
to ansible...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi everyone,

I found some nice articles how to bootstrap FreeBSD machines with
ansible, as they lack a python install by default. Seems
bootstrapping pkg and installing python seems to be enough.

http://lampros.chaidas.com/index.php?controller=post&action=view&id_po
st=56
https://blog.codeways.org/ansible-freebsd/
https://docs.ansible.com/ansible/intro_bsd.html

But when using these kind of commands with ansible 2.0 from a OSX
machine, the command always hangs. When killing the process on the
freebsd machine, I get output similar to this:

> ansible -vvv -k -u root XYZ -m raw -a 'env ASSUME_ALWAYS_YES=YES
> /usr/sbin/pkg bootstrap -f' SSH password: <XYZ> ESTABLISH
> CONNECTION FOR USER: root on PORT 22 TO freebsdmitnat
[...]
> <XYZ> EXEC /usr/sbin/pkg bootstrap -f XYZ | FAILED | rc=143 >>
> The package management tool is not yet installed on your system.
> Do you want to fetch and install it now? [y/N]: Beendet

Apparently the ASSUME_ALWAYS_YES variable does not get set, and thus
the commands ask for confirmation (last two lines of output). When
calling the whole 'env ... -f' command on the freebsd machine, this
works like a charm.

I also tried using root, using a user via sudo or su, but each time
the same behaviour.

Question:
Is this a (known) regression with ansible 2.0 or earlier? All the
articles are a little bit old, maybe this has changed in the meantime?

Anyone having a solution?

Setting ansible_shell_type to csh via host_vars/group_vars/... does
not work.

Thanks in advance,

Johannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with SeaMonkey - http://www.enigmail.net/

iEYEARECAAYFAla7j8MACgkQzi3gQ/xETbJ5+gCfePGwiuyJHJMKhmPGuw0PtcXV
h6IAn3TRa5NE2a4qEsevMeOEtFB0olzT
=SWhi
-----END PGP SIGNATURE-----

Johannes Kastl

unread,
Feb 17, 2016, 2:06:17 PM2/17/16
to ansible...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi everyone,

as I got no responses, I'll keep the full quote.

No one provisioning FreeBSD machines anymore? Or is this working for
everybody else, but not for me?

Thanks,
Johannes
iEYEARECAAYFAlbExJgACgkQzi3gQ/xETbLaiwCeLD5tEIWGXd8Y3IRgT4M8Zbh0
cC4An0vjf/QG+QcES2TrmkaHiiNNct+Q
=5E3Y
-----END PGP SIGNATURE-----

Johannes Kastl

unread,
Mar 29, 2016, 4:39:43 AM3/29/16
to ansible...@googlegroups.com
Am 10.02.16 schrieb Johannes Kastl:

> Question:
> Is this a (known) regression with ansible 2.0 or earlier? All the
> articles are a little bit old, maybe this has changed in the meantime?

I opened issue 15191:
https://github.com/ansible/ansible/issues/15191

Johannes

signature.asc

Johannes Kastl

unread,
Mar 29, 2016, 5:13:26 AM3/29/16
to ansible...@googlegroups.com
Am 29.03.16 schrieb Johannes Kastl:
...and I closed the issue, as I found the problem:

The quoted string has to be quoted again, otherwise the controller's
shell will eat the quotes and the "env ASSUME..." part...

Johannes


signature.asc

Johannes Kastl

unread,
Mar 29, 2016, 2:49:37 PM3/29/16
to ansible...@googlegroups.com
Am 29.03.16 schrieb Johannes Kastl:

>> I opened issue 15191:
>> https://github.com/ansible/ansible/issues/15191
>
> ...and I closed the issue, as I found the problem:
>
> The quoted string has to be quoted again, otherwise the controller's
> shell will eat the quotes and the "env ASSUME..." part...

Once again I eat my words. Seems to become a habit...

The twice-quoted command runs and returns a success message, but
apparently does nothing.

Using the following playbook works:

> - hosts: all
> gather_facts: false
> become_method: sudo
> become: yes
> tasks:
> - name: Bootstrapping pkg
> raw: /usr/sbin/pkg -N
> register: pkg
> ignore_errors: True
>
> - raw: /usr/bin/env ASSUME_ALWAYS_YES=1 /usr/sbin/pkg bootstrap -f
> when: pkg|failed
>
> - name: install python
> raw: /usr/sbin/pkg install -y python27

So it seems to be some kind of quoting hell. How to quote the argument
for the raw module in a way that everything works?

> ansible -m raw -a 'env ASSUME_ALWAYS_YES=YES pkg bootstrap -f' foobar
hangs waiting for the confirmation

> ansible -m raw -a "env ASSUME_ALWAYS_YES=YES pkg bootstrap -f" foobar
hangs waiting for the confirmation

> ansible -m raw -a '"env ASSUME_ALWAYS_YES=YES pkg bootstrap -f"' foobar
returns with success, but does nothing

> ansible -m raw -a "'env ASSUME_ALWAYS_YES=YES pkg bootstrap -f'" foobar
returns with success, but does nothing

> ansible -m raw -a "\"env ASSUME_ALWAYS_YES=YES pkg bootstrap -f\"" foobar
returns with success, but does nothing

Regards,
Johannes


signature.asc

Uditha Desilva

unread,
Mar 30, 2016, 7:04:05 PM3/30/16
to Ansible Project
Quoting the "=" seems to do the trick at least in my trivial test:

$ ansible -v -m raw -a 'env -i ABC\=blah /usr/bin/printenv' localhost
Using /etc/ansible/ansible.cfg as config file
localhost | SUCCESS | rc=0 >>
ABC=blah

Johannes Kastl

unread,
Mar 31, 2016, 4:07:33 AM3/31/16
to ansible...@googlegroups.com
On 31.03.16 at 01:04 Uditha Desilva wrote:
> Quoting the "=" seems to do the trick at least in my trivial test:
>
> $ ansible -v -m raw -a 'env -i ABC\=blah /usr/bin/printenv' localhost
> Using /etc/ansible/ansible.cfg as config file
> localhost | SUCCESS | rc=0 >>
> ABC=blah

Interesting, I did not think of the equal sign being the problem. I'll
run some tests against a FreeBSD host and report back...

Johannes

signature.asc

James Cammarata

unread,
Mar 31, 2016, 10:12:42 PM3/31/16
to ansible...@googlegroups.com
That should be fixed in the latest versions of devel/stable-2.0.

James Cammarata

Ansible Lead/Sr. Principal Software Engineer
Ansible by Red Hat
twitter: @thejimic, github: jimi-c


Johannes

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/56FCDAB7.5030607%40ojkastl.de.
For more options, visit https://groups.google.com/d/optout.

Johannes Kastl

unread,
Apr 1, 2016, 4:59:06 AM4/1/16
to ansible...@googlegroups.com
On 31.03.16 01:04 Uditha Desilva wrote:
> Quoting the "=" seems to do the trick at least in my trivial test:

I can confirm that quoting the equal sign works.

Thanks for testing!

Johannes


signature.asc
Reply all
Reply to author
Forward
0 new messages