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

Ansible import role run conditionally

I am writing a parent ansible role that runs another role though import_role. The idea that this sibling role (staticdev.pyenv) only runs when an argument pyenv_python_versions is passed, otherwise this is skipped. According to the official…
staticdev
  • 2,950
  • 8
  • 42
  • 66
1
vote
1 answer

How are files run in a Files folder in an ansible Role?

I have an ansible playbook, deploy_app_prod.yml, that calls the app_beanstalk ansible role ├── app_beanstalk │   │   ├── README.md │   │   ├── defaults │   │   │   └── main.yml │   │   ├── files │   │   │   ├── extensions │   │   │   │   ├──…
David
  • 61
  • 4
1
vote
1 answer

instrument datadog agent by the location of logs file with datadog ansible role

I tried to enable logs collecting with datadog ansible role, but I can't figure out why the logs are not sent to the Datadog ui I found an example of a playbook in the role GitHub repo, - hosts: servers roles: - { role: datadog.datadog,…
Hamza AZIZ
  • 2,582
  • 1
  • 9
  • 18
1
vote
1 answer

How to use with_sequence in Ansible

I want to run ansible role by iterating it through count of value that I am providing. Say for example: Below is the Ansible role main.yml, in which I include a yaml file to execute where this included yaml file should execute the number of times…
Alfred Hitchkock
  • 357
  • 2
  • 14
1
vote
1 answer

Creation of several users with access to a personal database

Needed to create seven databases, for each database you need one user with the same name as the database. db_names: - keystone - neutron - glance - placement - nova - nova_api - nova_cell0 - name: Create user with password …
Kaber
  • 35
  • 5
1
vote
1 answer

I have used register variable to store output values of task so i'm using same value in when condition from ansible role

--- - name: Check the apps list in ArgoCD server with related to cluster:"{{clustername.stdout}}" shell: | argocd app list | grep {{clusterip.stdout}} | grep {{proj_name}} | awk '{print $1}' register: applist - debug: var:…
Haridvpsk
  • 91
  • 1
  • 11
1
vote
0 answers

Ansible package installation as meta dependency or task

This is a design / architecture question to resolve my messed-up brain :) With ansible I want to install a package on my systems via role. There are two ways in this discussion: Specify the package(s) as role dependency in…
Nortol
  • 399
  • 3
  • 9
1
vote
0 answers

Extending role variables Ansible

I am having an Ansible role. In this role, I have vars/main.yml file. In the same directory, I would like to have "secret.yml" file containing vault encrypted variables. What would be the syntax for "main.yml" file to pull the role-wide variables…
silvermat
  • 161
  • 1
  • 1
  • 7
1
vote
1 answer

Calling roles in a loop using dictionaries from an array as vars

My question is somehow similar to the one posted here, but that doesn't quite answer it. In my case I have an array containing multiple vars: entries, which I loop over when calling a certain role. The following examples shows the…
Migsi
  • 107
  • 2
  • 10
1
vote
1 answer

How to populate parameters for an ansible role dynamically from a json file?

I'm working on passing parameters/vars to an ansible role dynamically by reading them from a JSON file. Consider the following role call (with optional parameters like phone, address, email, city) - name: Ansible role | Create include_role: …
r0r0n0a
  • 173
  • 2
  • 2
  • 10
1
vote
1 answer

Ansible Role design

just a short question which came to my mind in the last days: When you write roles lets say for a specific object type (AWS EC2 instance), do you write single roles for each operation like VM-Create, VM-Destroy, VM-Reboot .... or do you pack them…
Cl0uDius
  • 11
  • 2
1
vote
0 answers

Ansible shell module auto-escaping backslashes

I just started using Ansible for my home project and I am having problems with the Ansible shell module. From my host_vars I define a list of bash commands to be executed: commands: - sed -i -E 's/\/var\/www\/html/\/var\/www\/public/'…
Roy Lenferink
  • 311
  • 3
  • 10
1
vote
1 answer

Conditionally incude ansible role's variable files

Ordinarily I would dump variables in roles/myrole/defaults/main.yml. I don't need to explicitly include them - that's done for me automatically. But let's say I need to support Debian and CentOS and have identical variables with different values.…
lonix
  • 14,255
  • 23
  • 85
  • 176
1
vote
1 answer

Override Ansible hosts on a specific role

I have a playbook like below - name: Do something hosts: "view-servers" roles: - { role: role1, var1: "abc" } - { role: role2, var2: "def" } - { role: role2, var2: "ghi" } The servers in view-servers are identical and replicated. So…
Wins
  • 3,420
  • 4
  • 36
  • 70
1
vote
2 answers

Using Ansible variable across roles in different files

Here I am trying to perform the below-listed activities Deregister Instance from Application Load Balancer Deploy Application Register back the same instance on the Application Load Balancer The use case is to add back the deregistered instance…
Lijo Abraham
  • 304
  • 1
  • 2
  • 17