I am trying to create a playboook that executes a python3 script with 2 parameters, name and password in localhost.
However, when i try to execute the paybook with this command ansible -b --become-user=ras createdeploy.yaml --extra-vars "user=ras pass=ras"
I get this error message:
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
ERROR! Invalid variable name in vars specified for Play: 'pass' is not a valid variable name
The error appears to have been in '/home/ras/createdeploy.yaml': line 3, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
vars:
user: "{{ user }}"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
Here you are the .yaml file:
- hosts: all
vars:
user: "{{ user }}"
pass: "{{ pass }}"
tasks:
- name: Stop services
shell: "bash stopservices.sh"
- name: Edit real hosts file
shell: "bash editrealmachinehosts.sh"
- name: Create dirs and cloning
command: python3 user pass