Ansible:模块:路径不支持的参数”

时间:2020-03-19 09:17:14

标签: ansible

我是Ansible的新手,目前正在研究使用 Ansible path 模块替换给定单词中的单词的小剧本文本文件。

剧本:test.yml

-  name: Update the provided system to the next version
   hosts: localhost
   run_once: true
   vars:
    prev_version: "{{ PREVIOUS_VERSION }}"
    next_version: "{{ NEXT_VERSION }}"
   tasks:      

   - name: Update the software version
     replace:
       path: /home/hamza/TrainingWorkspace/Ansible/application_config.txt
       regexp: prev_version|string
       replace: next_version|string

文本文件:application_config.txt

version_info: "2020.2.2"

资源目录如下:

hamza@hamza-XX:~/TrainingWorkspace/Ansible$ ls
application_config.txt  test.yml


hamza@hamza-XX:~/TrainingWorkspace/Ansible$ pwd
/home/hamza/TrainingWorkspace/Ansible

如果我运行剧本:

ansible-playbook --connection=local --inventory 127.0.0.11, test.yml --extra-vars ' {"PREVIOUS_VERSION":"2020.2.2", "NEXT_VERSION": "2020.99.99"}'

我会收到以下错误:

    PLAY [Update the provided system to the next version] **************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [Update the software version] *********************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: path"}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   

注意:ansible-playbook 2.0.0.2

任何帮助将不胜感激?

1 个答案:

答案 0 :(得分:0)

replace module's doc中所述:

在Ansible 2.3之前,此选项仅可用作dest,destfile和名称。