ansible 错误记录
ansible 版本 |
---|
ansible 2.2.1.0 |
lineinfile 模块
在 ansible 2.2.1 版本中 lineinfile 模板还未识别 path 参数 ,报错如下
命令为:
[root@master ~]$ ansible node -m lineinfile -a ' \
path="/etc/my.cnf" \
regexp="^binlog-format" \
line="binlog-format = row"'
执行报错如下:
nova1 | FAILED! => {
"changed": false,
"failed": true,
"msg": "unsupported parameter for module: path"
}
正确参数为
[root@master ~]$ ansible node -m lineinfile -a ' \
dest="/etc/my.cnf" \
regexp="^binlog-format" \
line="binlog-format = row"'
执行成功。
nova1 | SUCCESS => {
"backup": "",
"changed": true,
"msg": "line replaced"
}
将 path 参数换为 dest;
原因是:
在ansible 2.8版本之前还未更新 path参数,在2.8版本之后才将 dest 更改为path