This is my current setup
Playbooks are parsed all at once, and roles which are “static”, are merged into the play at parsing time. They are required to exist before the playbook runs. You could however switch to include_role
, which loads the role when that “task” is encountered.
This is my current setup
---
- hosts: all
pre-tasks:
- local_action:
command ansible-galaxy install -r requirements.yml -p . (this install roles roleA, roleB, roleC)
roles:
- role1
- role2I have always an error message that it says that role1 doesn't exist... and I cannot see the first command being
executed even with a debug message - so I have the feeling it is always executing roles first and then pre-tasks,
however, I read that pre-task will be run first.... why does this doesn't apply here?Any idea?
No, I think it checks whether the roles are available before running the playbook. So if they are not accessible,
it terminates before performing any tasks.
I would use separate playbooks for the module installation and the execution of the roles.
Regards
Racke
so did that I had this error:
ERROR! ‘include_role’ is not a valid attribute for a Play
We use a shell wrapper around two playbooks: one that keeps a directory of roles updated, followed by a playbook that then uses those roles.
I did also that one for role installation and another play for the roles and then run them like there
- include_playbook: requirements.yml
- include_playbook: project.yml
but same error… roles are not founded ( which of course are not because the requirements.yaml hasn’t done the installation)
I tried requirement.yamls installing from GitHub but the playbook error was src is cannot be in a play and then with a task same as above but that didn’t install the roles first neither.
include_role
is a task, as such it must go under tasks:
a shell wrapper?
Got this and it seems that at least the syntax is not complaining anymore but got the following errors… I feel like I am close
fatal: [192.168.1.161]: FAILED! => {“msg”: “privilege output closed while waiting for password prompt:\nsu: Sorry\n”}
This is the current setup
I’m guessing you want become: false
on the local_action
, or some variant on that.
apparently
- local_action:
become: false
command ansible-galaxy install -r requirements2.yml -p .
ERROR! unexpected parameter type in action: <class ‘NoneType’>
What is your ansible.cfg looks . Actually it’s stores on your home directory/.ansible. Do a change on cfg that points to roles_path to this directory as well. This wil help you if you get roles doesn’t exist. Are you running in ansible engine or from ansible tower ?