I use Ansible to configure some virtual machines. I wrote a Python script that retrieves hosts from a REST service.
My virtual machines are organized in Media. For example, I have Test, Red, and Integration environments, each of which has a subset of virtual machines.
This Python script requires the user parameter --environment <ENV> retrieve the hosts of the required environment.
The problem I encountered is passing the <ENV> command to the ansible-playbook command. Actually the following command does not work
ansible-playbook thePlaybook.yml -i ./inventory/FromREST.py
I get an error message:
Usage: ansible-playbook playbook.yml ansible-playbook: error: no such option: --environment
What is the correct syntax for passing variables to a dynamic script resource?
Update:
To better explain, FromREST.py script takes the following parameters:
- Parameter
--list or parameter --host <HOST> in accordance with the Rules of dynamic inventory - The
--environment <ENVIRONMENT> parameter, which I added to those that Ansible needs to manage different environments
source share