How can I write variables inside the tasks file in ansible

后端 未结 5 1551
栀梦
栀梦 2021-01-31 07:26

I have this play.yml

---
- hosts: 127.0.0.1
  connection: local
  sudo: false

  tasks:
     - include: apache.yml

My Apache look

5条回答
  •  时光取名叫无心
    2021-01-31 07:41

    Whenever you have a module followed by a variable on the same line in ansible the parser will treat the reference variable as the beginning of an in-line dictionary. For example:

    - name: some example
      command: {{ myapp }} -a foo
    

    The default here is to parse the first part of {{ myapp }} -a foo as a dictionary instead of a string and you will get an error.

    So you must quote the argument like so:

    - name: some example
      command: "{{ myapp }} -a foo"
    

提交回复
热议问题