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

How to use a different entry point in ansible roles

Based on ansible documentation for roles I can make multiple role entry points by creating files: playbooks/roles/my_role/tasks/main.yml playbooks/roles/my_role/tasks/other.yml And I can add the default main.yml role using this code: --- - name:…
HubertNNN
  • 1,727
  • 1
  • 14
  • 29
6
votes
1 answer

Ansible role dependencies - install but don't run (yet) - how?

I want my roles to be reusable and self-contained. To be reusable, each role does a focused piece of work following the "single level of abstraction" paradigm. This leads to many small "atomic" roles, with layers of coordination roles building on…
Stevel
  • 631
  • 5
  • 13
6
votes
3 answers

Ansible: execute role only for some hosts

Let's say I have a single playbook with some roles for the installation of an appserver and I like to apply the same playbook on both production and testing servers. Both production and testing servers have the same list of roles, with the exception…
tvs
  • 737
  • 2
  • 17
  • 33
5
votes
1 answer

How to wait for ssh to become available on a host before installing a role?

Is there a way to wait for ssh to become available on a host before installing a role? There's wait_for_connection but I only figured out how to use it with tasks. This particular playbook spin up servers on a cloud provider before attempting to…
shellwhale
  • 820
  • 1
  • 10
  • 34
5
votes
4 answers

Import only tagged blocks from Ansible role

I want to import into playbook (and execute) only part of Ansible role defined in tagged block. E.g. I have role some_role containing 3 blocks of tasks tagged as tag1, tag2 and tag3. I could create playbook that imports whole role: --- - hosts:…
anlar
  • 477
  • 1
  • 11
  • 26
5
votes
1 answer

Using `vars_prompt` on Task file

Trying to use vars_prompt on main.yml task inside role but I get error: tasks/main.yml file for role 'roleName' must contain a list of tasks vars_prompt: - name: 'variableName' prompt: "Prompting User " private: no default:…
itms
  • 183
  • 2
  • 14
5
votes
3 answers

Ansible run always role

Is there any way to always run a role? I am creating lock file before starting any deployment to prevent parallel deployment. In case of any failure/success I want to delete the lock file. - { role: lock-deployment, tags: always } - { role:…
Lokesha S
  • 75
  • 1
  • 4
  • 16
5
votes
3 answers

Creating a dynamic role in ansible

After going through several documentation I concluded that, I can't use with_items for roles. So, I created a filter_plugin to generate a list of dictionaries for roles. Here is my Play: --- - name: Boostrap vpc and subnets with route table …
Suku
  • 3,820
  • 1
  • 21
  • 23
5
votes
1 answer

Specify version of role in Ansible playbook

When downloading roles it's possible to specify roles. One of several ways would be with the following requirements.yml file: --- - src: https://github.com/jdauphant/ansible-role-ssl-certs version: v1.5.2 This role could then be downloaded with…
Leonard Saers
  • 649
  • 9
  • 28
4
votes
1 answer

Ansible: applying tags at role execution

I'm trying to definitively understand how tags are applied at role execution in Ansible. I read the docs at https://docs.ansible.com/ansible/latest/user_guide/playbooks_tags.html#adding-tags-to-roles and tried with a test role: …
Mat
  • 586
  • 2
  • 10
  • 25
4
votes
2 answers

Serial execution of a role in Ansible

I have a playbook defined as below: - name: install percona rpms hosts: imdp roles: - role1 - role2 - role3 - role4 I just want the tasks defined in role 3 to be executed serially. If I define serial: 1 in the role3 tasks, it…
user2405589
  • 881
  • 2
  • 14
  • 32
4
votes
2 answers

How to use Azure DevOps server (TFS) Predefined Variable in My Ansible Playbook?

I want to use Azure DevOps Predefine Variable "$(Build.SourcesDirectory)" in My playbook: Here is my playbook: --- - hosts: KBR_MTL361 tasks: - name: copy file win_copy: src: D:\Web.config dest: $(Build.SourcesDirectory) I am…
4
votes
2 answers

How do I change owner permissions of a directory inside my elasticsearch docker container?

I have an elasticsearch docker container in my VM which works fine with elasticsearch version 2.3 installed using docker image. However on upgrading the elasticsearch to version 7.1.1 (using docker image), I received errors. While investing the…
4
votes
4 answers

ERROR! vars file vars not found on the Ansible Controller

ERROR! vars file vars not found on the Ansible Controller. If you are using a module and expect the file to exist on the remote, see the remote_src option. --- # tasks file for user-management - hosts: linux become: yes vars_files: -…
kaushik
  • 41
  • 1
  • 1
  • 3
4
votes
1 answer

Starting role from "tasks/alternate.yml" instead of "tasks/main.yml"

I have a large playbook that uses multiple roles to setup new servers. I'd like to re-use the playbook but for the decommission stage instead of calling into role_name/tasks/main.yml and having a lot of when: statements, I'd like to tell Ansible to…
dan_linder
  • 881
  • 1
  • 9
  • 30
1
2
3
14 15