Reputation: 151
I am currently trying to update all the wp-config.php files on multiple servers. This below should work but it wont allow me to use regexp for the destination.
Does anyone know an alternate way to do this?
---
- hosts: blah.blah.net
user: blah
sudo: true
tasks:
- name: add a new string before the match
lineinfile: dest='\/home\/.*\/public_html\/wp-config.php'
regexp='^\/\*\* MySQL database password \*\/'
insertbefore='^\/\*\* MySQL database password \*\/'
line='define("DISALLOW_FILE_MODS", true);'
Upvotes: 2
Views: 2370
Reputation:
As you've already experienced, a regular expression won't work there. What I recommend is to use with_items
like this:
- name: add a new string before the match
lineinfile: dest=/home/{{ item }}/public_html/wp-config.php
regexp=' ... '
with_items:
- usera
- userb
- userc
You can obtain a list of items from a file (with_lines: cat filename
) or by obtaining them remotely (i.e. from the managed nodes) with, say, a shell
action and a register: variable
.
Upvotes: 5