Questions tagged [ansible-role]

Ansible role is a set of tasks to configure a host to serve a certain purpose like configuring a service, whereby they are defined using YAML files with a predefined directory structure, as part of the provisioning, configuration management, and application-deployment tool Ansible. Use this tag for questions related to the role tasks in Ansible.

Ansible role is a set of tasks to configure a host to serve a certain purpose like configuring a service, whereby they are defined using YAML files with a predefined directory structure, as part of the provisioning, configuration management, and application-deployment tool Ansible. Use this tag for questions related to the role tasks in Ansible.

224 questions
1
vote
2 answers

Managing Ansible Roles for many projects

Description The Ansible content organization documentation only talks about a single project with multiple staging environments. That is great and all, but I need to manage many projects that will be reusing a lot of the same Ansible roles. Should I…
aidanmelen
  • 6,194
  • 1
  • 23
  • 24
1
vote
1 answer

Ansible role with shared python virtual environment

I have ansible role which have task delegated to localhost: - name: Test role hosts: my_hosts gather_facts: no tasks: - name: Register remote hosts include_role: name=register_remote_hosts delegate_to: localhost The…
sq8ijk
  • 21
  • 3
1
vote
1 answer

Ansible does not install dependency from Git SCM

I am trying to create a new Ansible role called "Adminer" which requires the "Apache" role. I've specified the Apache role as a dependency in meta/main.yml: --- dependencies: - src: git+https@github.com:alexandrubau/ansible-apache.git name:…
Alexandru
  • 833
  • 1
  • 8
  • 24
1
vote
1 answer

Ansible Alternative directory structure requires paths

I am trying to create the Alternative Directory Layout from the Ansible docs site best practices section. Following this guidance, here is the layout that I have created inside ~/ansible_proj/windows_setup (windows_setup is a Python virtual…
edesz
  • 11,756
  • 22
  • 75
  • 123
1
vote
1 answer

Parameter remote_user in role include is deprecated, what's the workaround?

I'm using Ansible to do the automation of my systems. I have an Ansible playbook that depends on two roles. The first role creates a user ("specific_user") on a remote server. The second role uses this user to do a bunch of stuff. My first solution…
MMacphail
  • 541
  • 3
  • 19
1
vote
2 answers

Ansible - multiple roles

I am trying to run multiple roles using with_items command, however I am getting error: "ERROR! 'item' is undefined" role.yml: --- - hosts: '{{ host }}' become: yes roles: - role: "{{item}}" with_items: "{{ roles }}" Here is my…
MMA
  • 408
  • 3
  • 7
  • 19
1
vote
3 answers

Run handlers regardless of task failure?

I have an Ansible role which has the following tasks: --- # optionally find the latest version of goss using the GitHub "API" - name: detect latest version shell: | curl -sIS https://github.com/aelsabbahy/goss/releases/latest | \ tr…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
1
vote
1 answer

Conditional Ansible roles fail when already executed

I have a role that I would like to execute multiple times, each execution with a different var. However, I would also like some of those executions to be conditional. Here is a main.yml: - hosts: localhost roles: - { role: test,…
Mark
  • 12,359
  • 5
  • 21
  • 37
1
vote
1 answer

Can there be a directory structure within the Ansible role templates or files folders?

The basic directory structure of an Ansible role is: rolename files templates tasks ... Now my question is can the files or templates folders have a directory structure inside them like this: rolename files templates etc …
danday74
  • 52,471
  • 49
  • 232
  • 283
1
vote
1 answer

Ansible roles YAML error

Testing a basic Ansible roles setup but got an error on the first line of a role main.yml, I am sure it's something silly though play.yml - hosts: myhosts remote_user: myuser roles: - test Directory…
Bob
  • 8,424
  • 17
  • 72
  • 110
1
vote
1 answer

Dependent role is not running

Background I am experimenting with Ansible (1.9.4) roles and I am trying to get the hang of role dependencies. I have created the following roles: A role that installs the Oracle JDK (ansible-java8) A role that installs Tomcat…
gregwhitaker
  • 13,124
  • 7
  • 69
  • 78
0
votes
0 answers

Ansible cannot find the requested handler that is within the same role

I am running a playbook that includes a role with the roles: key. When a task within the role notifies a handler within the role it throws the following error. ERROR! The requested handler 'Build eigen' was not found in either the main handlers list…
Braedon
  • 41
  • 1
  • 5
0
votes
2 answers

Ansilbe Playbook Tasks Running Twice

I've spent an obscene amount of time trying to get this playbook/role to work correctly. When I use the tags I've assigned the tasks in the playbook it runs the tagged task and then all the tasks. I added the "never" tag and it still runs all the…
0
votes
1 answer

How to list files in an ansible role folder

I'm struggling to get a list with all files under a subfolder of templates role folder using the find module, So to use it afterwards and delete all remote files which are not included in my role folder. Here is the task inside my role: - name:…
Manos K
  • 23
  • 4
0
votes
4 answers

ansible : replace line in file with new values depending of original values

With loop or other, I can't see how to use the replace or inline module to achieve that. The orinal file contains this line goals first_goal + second_goal I only want to modify the line starting with goals (with leading spaces or not) With these…
troubadour
  • 253
  • 3
  • 10