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
0 answers

ansible set_fact in a role, is this possible?

I have a role in a playbook which gets a value from a query. That value should then be available in other roles. I tried: root-play.yml: roles: - update - role: query tags: query - process The query role: - name: Query data …
transient_loop
  • 5,984
  • 15
  • 58
  • 117
0
votes
1 answer

how to have single ansible role for both windows as well as for linux?

I want to achieve a common ansible role. And conditions are : without using gather_facts (which basically allows us to check os_family for linux). The way I have been doing it is with inventory group [windows] & when condition with playbooks…
Abid Khan
  • 145
  • 2
  • 9
0
votes
0 answers

How to properly refer to a host from within a role?

I am currently using in defaults/main.yml: myRoleName_host: "{{ ansible_host }}" but some people feel we shouldn't use ansible_host. I know we can reference from host_vars but from within the role you have no guarantee about the host name, so that…
achyrd
  • 401
  • 1
  • 3
  • 9
0
votes
1 answer

Ansible: Command line option 'd' [from -d,] is not understood in combination with the other options

UPDATE: Though this Q has been marked as a typo (and therefore "less useful to users"), the issue was actually needing to use the correct ansible module; shell, rather than the command module. I'm hoping someone can show me where I'm going wrong…
neile
  • 27
  • 7
0
votes
1 answer

Common use case of ansible roles

I just initialize ansible project and not sure which approach is better to create ansible roles. Should I create one usecase per roles. Or it is better to create multiple usecase inside one roles. For example, I have this multiple roles which…
geralvin
  • 73
  • 7
0
votes
0 answers

Ansible role implies another role

I have Ansible roles A and B. When A is applied to a server, B is also applied. Currently I'm specifying this manually, but this is error prone, so when I add a server I could add role A and forget role B. Is there a way to do this automatically? I…
0
votes
2 answers

What is the best way to deal with Ansible's import_tasks/import_role and "notify"?

Here is a very simple code fragment taken from my "kafka" role: - import_role: name: java notify: - restart kafka - restart zookeeper Basically I want to install Java running "java" role and when there are changes performed by that…
Erikas
  • 1,006
  • 11
  • 22
0
votes
1 answer

Having issue with delegate_to in playbook calling a role to only run on one host in a list

I have a playbook and only want to run this play on the first master node. I tried moving the list into the role but did not see to work. Thanks for your help! ## master node only changes - name: Deploy change kubernetes Master remote_user:…
TyBoard
  • 1
  • 3
0
votes
0 answers

Error while calling variable with multiple values from vars file in a role

I am getting error while calling variable from vars files in tasks/main.yml of a role, vars/main.yml looks like below, ports: - "8080/tcp" - "80/tcp" And in tasks/main.yml, calling like below, - name: open firewall port firewalld: zone:…
user3132525
  • 123
  • 6
0
votes
1 answer

Ansible play fails due to github authentication

I am running a terragrunt script through the ansible play using the ansible shell module. Ansible task environment: AWS_ACCESS_KEY_ID: "{{aws_access_key_id}}" AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}" …
shamon shamsudeen
  • 5,466
  • 17
  • 64
  • 129
0
votes
1 answer

The best way to authorize ssh key of each node to all nodes in the cluster

I want to create a cluster infrastructure that each node communicates with others over shh. I want to use ansible to create a idempotent playbook/role that can be executed when cluster initialized or new nodes added to cluster. I was able to think…
Doruk Eren Aktaş
  • 2,121
  • 8
  • 23
0
votes
0 answers

ansible role, call from commandline weird behaviour

I have a ansible role with the simple task of a finding some files in multiple paths and a debug statement showing what it did find, looks like this: - name: "find smth" find: paths: "{{ search_path }}" file_type: file patterns:…
0
votes
1 answer

Execute Ansible tasks based on role execution status

I've a role pkg_install, is there any way based on status of the role execution can we execute post_tasks? also ignore errors if role pkg_install failed? - name: status file hosts: localhost gather_facts: false roles: - role: "pkg_install" …
user8096150
0
votes
1 answer

Ansible playbook and roles

Hi can i know i have the below main playbook and inbside the role folder for file-transfer and deployment i have task. I would like to know below 1) what happen if task in file-transfer failed? will task at the deployment role execute or will it…
0
votes
2 answers

Ansible Debug msg to variable

Folks, I have the script below that i am using to create a list of all the block devices on my Linux machine, which have no partitions on them and later run the parted module to partition them. I am trying to save the value of item.key into a…
MikeKim
  • 11
  • 1
  • 3