我目前正在尝试更新多个服务器上的所有wp-config.php文件.下面这应该工作,但它不允许我使用正则表达式的目的地.
有没有人知道另一种方法呢?
---
- 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);'
Run Code Online (Sandbox Code Playgroud)
小智 5
正如您已经经历过的那样,正则表达式将不起作用.我建议使用with_items这样的:
- name: add a new string before the match
lineinfile: dest=/home/{{ item }}/public_html/wp-config.php
regexp=' ... '
with_items:
- usera
- userb
- userc
Run Code Online (Sandbox Code Playgroud)
您可以从文件(with_lines: cat filename)中获取项目列表,也可以远程(即从受管节点)获取项目列表,例如,shell操作和a register: variable.
| 归档时间: |
|
| 查看次数: |
1700 次 |
| 最近记录: |