Question:
I tried this:
1 2 3 4 |
- command: ./configure chdir=/src/package/ - command: /usr/bin/make chdir=/src/package/ - command: /usr/bin/make install chdir=/src/package/ |
which works, but I was hoping for something neater.
So I tried this which give me back “no such file or directory”
1 2 |
- command: ./configure;/usr/bin/make;/usr/bin/make install chdir=/src/package/ |
I tried below too:
but I couldn’t find the right syntax to put:
1 2 3 4 5 6 |
- command: "{{ item }}" chdir=/src/package/ with_items: ./configure /usr/bin/make /usr/bin/make install |
That does not work, saying there is a quote issue.
Answer:
If a value in YAML begins with a curly brace ({
), the YAML parser assumes that it is a dictionary. So, for cases like this where there is a (Jinja2) variable in the value, one of the following two strategies needs to be adopted to avoiding confusing the YAML parser:
Quote the whole command:
1 2 3 4 5 6 |
- command: "{{ item }} chdir=/src/package/" with_items: - ./configure - /usr/bin/make - /usr/bin/make install |
or change the order of the arguments:
1 2 3 4 5 6 |
- command: chdir=/src/package/ {{ item }} with_items: - ./configure - /usr/bin/make - /usr/bin/make install |