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

**URL:** <https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523>\
**Category:** Ansible Project\
**Created:** [February 10, 2016, 7:30pm UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523 "2016-02-10T19:30:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [February 10, 2016, 7:30pm UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/1 "2016-02-10T19:30:17Z")

</div>

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](http://lampros.chaidas.com/index.php?controller=post&action=view&id_po)  
st=56  
[https://blog.codeways.org/ansible-freebsd/](https://blog.codeways.org/ansible-freebsd/)  
[https://docs.ansible.com/ansible/intro\_bsd.html](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

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [February 17, 2016, 7:06pm UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/2 "2016-02-17T19:06:05Z")

</div>

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

> 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\_](http://lampros.chaidas.com/index.php?controller=post&action=view&id_)

po

> 

st=56

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [March 29, 2016, 8:39am UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/3 "2016-03-29T08:39:26Z")

</div>

I opened issue 15191:  
[https://github.com/ansible/ansible/issues/15191](https://github.com/ansible/ansible/issues/15191)

Johannes

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [March 29, 2016, 9:13am UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/4 "2016-03-29T09:13:11Z")

</div>

...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

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [March 29, 2016, 6:49pm UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/5 "2016-03-29T18:49:19Z")

</div>

> > I opened issue 15191:  
> > [https://github.com/ansible/ansible/issues/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  
> &nbsp;&nbsp;gather\_facts: false  
> &nbsp;&nbsp;become\_method: sudo  
> &nbsp;&nbsp;become: yes  
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;- name: Bootstrapping pkg  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raw: /usr/sbin/pkg -N  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: pkg  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore\_errors: True
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- raw: /usr/bin/env ASSUME\_ALWAYS\_YES=1 /usr/sbin/pkg bootstrap -f  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: pkg|failed
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- name: install python  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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

---

<div class="post-metadata">

**Author:** ![Uditha\_Desilva](https://avatars.discourse-cdn.com/v4/letter/u/f475e1/32.png) [@Uditha\_Desilva](https://forum.ansible.com/u/Uditha_Desilva)\
**Post date:** [March 30, 2016, 11:04pm UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/6 "2016-03-30T23:04:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [March 31, 2016, 8:07am UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/7 "2016-03-31T08:07:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [April 1, 2016, 2:12am UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/8 "2016-04-01T02:12:37Z")

</div>

That should be fixed in the latest versions of devel/stable-2.0.

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [April 1, 2016, 8:58am UTC](https://forum.ansible.com/t/bootstrapping-freebsd-with-ansible-2-0-raw-module-does-not-work-anymore/20523/9 "2016-04-01T08:58:55Z")

</div>

I can confirm that quoting the equal sign works.

Thanks for testing!

Johannes
