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

In ansible, how can I deploy different config files based on the host?

I would like to have a role that can deploy both ntp clients (hosts that point to internal ntp servers for time), and ntp server (hosts that point out to the internet for time). There is a nice link for how to do this with multiple roles, but since…
chuckbag
  • 11
  • 2
1
vote
2 answers

Ansible Role - Unable to detect Filter Plugin

Im trying to build a very simple plugin filter within a role. However, when I go to test the plugin it doesnt detect it. Ansible version is 2.9. dir (base) root@8c08139d265e:/workspace# tree . ├── Dockerfile ├── Makefile ├── README.md ├── defaults │…
felix001
  • 15,341
  • 32
  • 94
  • 121
1
vote
1 answer

Is a correct YAML file enough for a correct ansible playbook, syntax while executing a role?

ERROR! "unexpected parameter type in action: class 'ansible.parsing.yaml.objects.AnsibleSequence'" The error appears to be in '/home/ansible/march/roles/apache/tasks/apt.yml': line 2, column 3, but may be elsewhere in the file depending on the…
1
vote
1 answer

Is this a superfluous ansible tag?

While many may like ansible, to me it seems with it rather conflating and somewhat redundant concepts like tags, roles, inventory/hosts files, hostgroups, playbooks, tasks "when" conditionals there is quite some challange to determine what…
fraleone
  • 121
  • 4
1
vote
1 answer

Pattern for extending an ansible role variable that has a defaul value

I wonder if there is a standard/recommended way to modify a role variable in Ansible. As a role author you profile a set of defaults for your role and the user has the freedom to override these. The problem appears when that defaults are lists or…
sorin
  • 161,544
  • 178
  • 535
  • 806
1
vote
1 answer

Ansible Hostvars to List or Dictionary to match off in later task (key:value)

I have a basic role that will use hostvars from multiple files within group_vars titled with their group names to look at the sitecode and location of a particular office; - vars: code_location: [] set_fact: code_location: "{{…
Niall
  • 37
  • 7
1
vote
2 answers

How to rename an ansible role name?

I have created an ansible role with name suppose role_A. Now i was asked to follow standard naming convention as per company standard. so is there any way i can rename my role name. Or simply mv command will work for me.
manish jha
  • 43
  • 6
1
vote
1 answer

Run a task in an ansible role only if it has not run before or there is a version change

I have a task that installs a package from yum which takes a while to run every time I run the playbook. What I would like to do is only run a task only if it has not run before or the specified version in the default variables has changed. Anyone…
Anje3000
  • 11
  • 2
1
vote
1 answer

How can loop items as input parameters to a ansible role

I am trying to convert an existing ansible playbook (for extracting the webpage content of multiple webpage URL's in parallel fashion) to re-usable roles. I need the role to accept variables in a loop and produce the output for all the items in a…
TR007
  • 47
  • 1
  • 8
1
vote
1 answer

AWS/Ansible - How to access facts across roles/hosts from host defined in dynamic-inventory?

I am currently setting up a number of Ansible roles to setup a Kubernetes cluster. So far I have a role to provision idempotent EC2s (1x Master / 2x Worker) and subsequent roles to setup these master/worker nodes with Docker/Kubernetes dependencies.…
1
vote
1 answer

Ansible Custom Role (with custom command module)

I am trying to implement a custom network command module as an Ansible role. This module will run commands on remote devices. Ansible connection type is network_cli Created the role by using below command ansible-galaxy init --type=network…
rawat
  • 165
  • 1
  • 2
  • 15
1
vote
3 answers

Ansible provisioning without internet access

I know that you can setup proxy in Ansible to provision behind corporate network: https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html like this: environment: http_proxy: http://proxy.example.com:8080 Unfortunately in…
Maksim Luzik
  • 5,863
  • 4
  • 36
  • 57
1
vote
0 answers

How to use the with_items in wait_for module if I've created more than one instance?

The yml I've written works properly if I've created only one ec2instance but in case I've to provision more than 1 ec2 instances then this yml code fails. I want to wait for the ssh to come up for 2 different ec2 instances - name: 7. Wait for SSH…
Nitesh Jain
  • 167
  • 1
  • 3
1
vote
1 answer

tell Ansible to elm init

I have a ansible role for elm setup, and the last task is elm init, to configure initial elm project, but I'm having problem with this task because I need to tell yes when elm prompt me Hello! Elm projects always start with an elm.json file. I can…
copser
  • 2,523
  • 5
  • 38
  • 73
1
vote
0 answers

installing npm package.json ansible task

I want to install package.json using ansible, I'm using the example from the docs, only thing different from this is that I'm using npm not nvm so the tasks look like this - name: npm install (manual) npm: path:"{{ project_path }}" …
copser
  • 2,523
  • 5
  • 38
  • 73