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
0
votes
1 answer

Calling eddyhub.gnome_shell role (from ansible galaxy) from another role

I want to install gnome extensions in an ansible playbook and found this: https://galaxy.ansible.com/eddyhub/gnome_shell/ nice! The way I am organzing my playbook, I would like to call the role from within another task, so I created a task like this…
Nathan
  • 7,099
  • 14
  • 61
  • 125
0
votes
1 answer

Ansible exit code for a role or a playbook, not each individual task

Is it possible to capture an exit code for an Ansible role or playbook (not each individual task) and branch depending on the exit code? We have an application that needs to create a specific flag (success/failure) for each Ansible ROLE, not task.…
0
votes
1 answer

Ansible: Task structure of roles

I have 4 playbooks. 2 of them are deploying services on my target machines and 2 of them are removing them again. Now I want to put them in roles. But I'm not sure what the best-practice is. The 2 deploy playbooks are doing the exact same thing…
Forivin
  • 14,780
  • 27
  • 106
  • 199
-1
votes
0 answers

Running different role for different task with different variable

Currently, I'm refactoring all jobs backup from different type of DBs (mongo, mysql, postgres) to ansible roles. The structure is below. The thing here is different server have different DB's username, password, DB name. I don't want to use…
hoa.le
  • 13
  • 4
-1
votes
1 answer

Multiple remote users to work with ansible dynamic inventory

I am using dynamic inventory and i didn't find anything about how to run a playbook with more than one user. When i configure a specific remote user in my ansible.cfg file, the ssh connection works only for the OS types that uses that specific…
-1
votes
1 answer

how to use conditional statement in main.yml in ansible roles

I wanna apply role using conditional statement by centos version(7, 8) in yml There are tons of examples of conditional statement in the playbook. However, there seems to be no example of yml to be used in role. As in the example below I tried to…
S.Kang
  • 581
  • 2
  • 10
  • 28
-1
votes
1 answer

How to run tasks for roles I would select with limit?

In my playbook I have: roles: - role: role_1 - role: role_2 In my roles directory structure I have defined vars with different values under role_1 and role_2 When invoking the playbook, I am trying to ask it to only consider the role I am…
gk_2000
  • 194
  • 3
  • 16
-1
votes
1 answer

Ansible add apt_key

What can be the issue on the task file? this role should do this: add apt key for vscodium add vscodium repository install vscodium When i want use ansible $ansible-playbook /etc/ansible/ubuntu_real.yml this error is…
heavyblack1
  • 72
  • 2
  • 9
-1
votes
1 answer

How to use variables in with_items in anisble playbook

I have create ansible role to create multiple lambda function, where I am passing some parameters from variable file. My variable file looks like Variable file S3BucketName: "test_bucket" S3Key1: "test.zip" runtime: "python3.6" handler1:…
sonali shah
  • 39
  • 2
  • 6
-1
votes
1 answer

ansible: how to share varibles between roles

I need to permform few task on same hosts but wanted to group the tasks into the different roles which need to share some output to each other. Consider below example │── hosts ├── playbooks │ ├── Playbook1.yml │ ├── roles │ └── role1 │ …
va1bhav
  • 365
  • 1
  • 5
  • 21
-1
votes
1 answer

Ansible role checking path of dynamic variable within task

I have a couple of ansible role tasks which I am using to setup a number of configuration directories. The problem is that I have a list of configurations which need to be setup with a certain path but only if they do not exist. - name: Ensure core…
dcmbrown
  • 1,049
  • 9
  • 15
-1
votes
2 answers

How can I get the hosts running a certain role from within that role

I'm trying to setup a Zookeeper cluster and in order to set the url that points to the ZK nodes I would like to know which are the ip addresses of the hosts running the current role. I know that from the playbook I can pass the hosts machines…
Painy James
  • 805
  • 2
  • 13
  • 26
-2
votes
1 answer

Ansible: precedence for changes to the same file from three different roles

So, I was reading https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#using-allow-duplicates-true trying to figure out what's going wrong with my playbook. This playbook calls 9 roles, and 3 of them edit the same file…
rofz
  • 95
  • 8
-2
votes
1 answer

Ansible can't pass varibles to roles using lookup?

I want to pass some rsa public keys to ansible roles from ansible playbook, however, I find that ansible can't pass varibles when using lookup. --- - hosts: gateway vars: keys: - "{{ lookup('file', './files/rsa_pubs/sake1.pub') }}" …
sake
  • 387
  • 4
  • 12
1 2 3
14
15