It's raining new modules! Time to test them!

Maybe raining is not the word. More like "firestorm".

Documentation for the selinux, seboolean, lineinfile (newly
refactored), nagios, and wait_for modules are all up on the official
documentation site on the modules page.

Please help test all of these, along with new language features (also
documented on the advanced playbooks page) such as "delegate_to" and
"serial".

Documentation site is, of course: http://ansible.github.com

As a reminder, today's the feature freeze deadline for 0.7 -- and
we'll release about the same time next week.

The changelogs are looking incredible --
https://github.com/ansible/ansible/blob/devel/CHANGELOG.md

In other news, I've added a few more example playbooks and articles to
the Ansible-Resources page -- such as Matt's vagrant tutorial and
Chris Gedding's rather extensive playbook example --
https://github.com/ansible/ansible-resources/blob/master/README.md.
It is very interesting to see how everyone is using things in
different ways, so keep sharing great content like this!

--Michael

Yay lineinfile! Here’s my problem:

Source file has:

$DB[“USER”] = “zabbix”;
Desired:

$DB[“USER”] = “<interpolate playbook variable $mysql_Zabbix_user>”;

Here’s what I’ve tried so far:

action: lineinfile name=/etc/zabbix/dbconfig.php regexp=^$DB[“USER”] line=‘$DB[“USER”] = “$mysql_Zabbix_user”’
action: lineinfile name=/etc/zabbix/dbconfig.php regexp=^$DB[“USER”] line=‘$DB[“USER”] = "$mysql_Zabbix_user"’

action: lineinfile name=/etc/zabbix/dbconfig.php regexp=‘^$DB[“USER”]’ line=‘$DB[“USER”] = “$mysql_Zabbix_user”’
action: lineinfile name=/etc/zabbix/dbconfig.php regexp=‘^$$DB[“USER”]’ line=‘$DB[“USER”] = “$mysql_Zabbix_user”’

action: lineinfile name=/etc/zabbix/dbconfig.php regexp=‘^$DB[“USER”]’ line=‘$DB[“USER”] = “$mysql_Zabbix_user”’

All of which give this error:

failed: [host] => {“failed”: true, “msg”: “line= doesn’t match regexp=”}

The debug output seems only slightly-useful:

REMOTE_MODULE lineinfile name=/etc/zabbix/dbconfig.php regexp=^$DB[“USER”] line=‘$DB[“USER”] = “monitorZabbix”’

I’m not sure from examples what the regexp escaping rules are, nor what the generic playbook escaping rules are, and it looks like I’ll need to understand both to get this case to work properly.

Confucious says, "If a man has a problem, and solves it with a regex,
man now has two problems".

Thankfully, it's not that bad.

Remember that "$" represents "end of string" in a Python regular
expression, and that "[" and "]" are also meaningful. The escape
character is "\" and not "$".

This worked for me:

    action: lineinfile name=/tmp/testfile regexp='^\$DB\[\"USER\"\]'
line='$DB["USER"] = "foo"'

Aha! Escape all of $, [, ], quotes. That works for me, too. For posterity, the actual code I’m now using in my Playbook is:

action: lineinfile name=/etc/zabbix/dbconfig.php regexp=‘^$DB["USER"]’ line=‘$DB[“USER”] = “$mysql_Zabbix_user”’

This might be a useful example for the lineinfile module documentation.

FWIW, you should not need to escape quotes, but that is sometimes
easier than telling what is "'" and what is '"' when they are all run
up against one another.