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
4
votes
2 answers

Double with_items loop in ansible

I want to create a double loop in ansible. I have one things like this : userslist: - name: user1 primary : user1-group groups : - group1 - group2 - name: user2 primary : user2-group groups : - group3 …
p305
  • 125
  • 1
  • 1
  • 14
4
votes
2 answers

Ansible - list tasks in role

Is it possible to list the tasks in an Ansible role? i.e. other than just grepping for - name, is there an out-of-the-box way of doing this?
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
4
votes
2 answers

How to always run some ansible roles after previous failures?

I have a set of playbooks that do look like - name: Run test hosts: tester roles: - { role: setup_repos } - { role: setup_environment } - { role: install_packages } - { role: run_tests } - { role: collect_logs } The current…
sorin
  • 161,544
  • 178
  • 535
  • 806
4
votes
1 answer

Why Ansible facts not available in Roles section?

Question Why Ansible facts such as ansible_distribution are not available in Roles section? --- - name: Test hosts: all tasks: - name: debug debug: msg: "{{ ansible_distribution }}" <----- Works roles: - "{{…
mon
  • 18,789
  • 22
  • 112
  • 205
4
votes
2 answers

Ansible - how to improve skipped roles performance

I have a playbook which calls some roles which are skipped. For illustration, I have created a dummy playbook with dummy roles. Everyone of these roles is skipped. --- - hosts: localhost connection: local gather_facts: false roles: - {…
user140547
  • 7,750
  • 3
  • 28
  • 80
4
votes
1 answer

Ansible not detecting Role default variables in its handler

Does ansible pass Role Default variables to the Handlers within the same Role? Here's a minimal excerpt of the playbook that has the issue: Role hierarchy - playbook.yml - roles/ - gunicorn/ - defaults/ - main.yml - handlers/ -…
rtindru
  • 5,107
  • 9
  • 41
  • 59
4
votes
2 answers

Define Ansible variable in a role with OS specific default which can be easily overridden

I'm writing an Ansible role that is usable on different Linux OS families and has a different default value for variables per OS family. At first, I thought this would be easy to set up using an include vars task in the role, such as: - name: Gather…
Dave B
  • 41
  • 1
  • 3
3
votes
2 answers

Ansible: how to achieve idempotence with tasks that append files on host (w/o reverting to initial state)

I am having a hard time getting to know how to create Ansible roles that are following the best practices according to documentation. The following use-case which I am looking at is e.g. enabling Filebeat on host. Filebeat can be configured by…
gczarnocki
  • 173
  • 1
  • 16
3
votes
2 answers

Ansible share roles between repository

We have 3 repository, let say repo Y,Z and W. There are roles under repository W that repository Y and Z want to use. From reading, it seem we need to set requirements.yml as below, - src: git@github.com:SOMEREPOSITORY/test-role.git version:…
MrAZ
  • 394
  • 3
  • 13
3
votes
1 answer

ansible: Variable not reinitialized using a role

i have a strange behaviour that i don't understand Playbook "vars_roles.yml": --- - hosts: localhost gather_facts: no vars: msg_role3: "first_run" roles: - role: role3 - hosts: localhost gather_facts: no vars: msg_role3:…
Florent
  • 59
  • 4
3
votes
2 answers

Ansible - How to zip files in localhost before copying to remote

I am trying to copy large sets of files (in 100's) to my remote server. However, using 'copy' command this task is taking considerably long time. Searching a bit, I understood the 'synchronize' is a good suit for this. Unfortunately my current…
akash
  • 864
  • 8
  • 13
3
votes
2 answers

Does ansible support modules written in Go?

Ansible supports custom modules written in Python . For execution types which are not local( local mean connection: local & hosts: localhost), ansible ssh's python packages to remote node, for every play. Does ansible support writing modules in…
overexchange
  • 15,768
  • 30
  • 152
  • 347
3
votes
1 answer

Ansible: Can't set variable for sequential execution

I'm trying to build a playbook with rolling update use case (Sequential Execution) with the serial element. Since I have to use the serial value in multiple places in the playbook, I wanted to use it as a variable which can be used to define…
rolz
  • 591
  • 2
  • 11
  • 23
3
votes
0 answers

Ansible not executing handlers from dependency roles for all hosts

Setup I have several roles which declare role dependencies and sometimes use handlers from roles they depend on. A simplified version of my setup looks like this (This is the output of head inventory **/*.yml and it shows all path names and the…
3
votes
1 answer

Ansible: applying role templates hierarchically

I'm planning to use Ansible to manage a fairly large set of Linux servers with a lot of variation among them. The hosts will be grouped into roles with a hierarchy between them, there's a common role, on which every other depends, child-roles which…
André Fernandes
  • 2,335
  • 3
  • 25
  • 33
1 2
3
14 15