Questions tagged [ansible-playbook]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
9 views

How to filter shell result

We have run a playbook with shell module to retrieve data using curl command we are able retrieve data but that data containing lot of information so would like filter that data. can some one tell ...
0
votes
1answer
14 views

Passing the list of values to a python script as arguments inside ansible script

I have a python script inside ansible playbook: --- - hosts: localhost become: yes become_method: sudo become_user: root gather_facts: false tasks: - name: execute script ...
0
votes
0answers
11 views

Ansible playbook “path specified in src not found”

I am runnning into this message when I do this : ansible-playbook -i inventory junos_config_new.yml --check -vvv ansible-playbook 2.9.9 config file = /etc/ansible/ansible.cfg configured module ...
0
votes
1answer
18 views

How to separate variables using awk and append it to Text file using ansible

What I got as extra variable to ansible playbook is "CHOW_app/timmy_app1/johnn_app3/harper_app4/mona_app5". This is passed as single variable to the playbook. I have to separate it and save it in a ...
0
votes
1answer
86 views

How to stop the playbook if the service is already installed using win_service module?

How to stop the playbook if the service is already installed? I am trying: - hosts: windows tasks: - name: check services win_service: name: serviceName register: ...
0
votes
0answers
17 views

parsing debug information from ansible k8s_info module

I'm testing the ansible k8s_info module and having a challenge parsing the result in a register variable. The playbook gets pods from all namespaces. My objective is to print only the spec.containers ...
0
votes
1answer
8 views

Ansible: Index value in template file per instance

I am trying to deploy multiple instances of a service on a single host. The service has a config file, and in this config file, I'd like to include the index of the instance that it belongs to. For ...
0
votes
0answers
17 views

How can I delete an OpenStack volume snapshot older than 10 days?

How can I delete an OpenStack volume snapshot older than 10 days? Below the playbook that I use to create the volume, but I want to implement also the deletion. --- - name: Creating a volume ...
-1
votes
1answer
43 views

List tags that exists in a playbook

I have a play that runs one or more roles. I would like to list available tags without parsing all the code. I am indeed experimenting some difficulties in remembering all the tags I put during ...
0
votes
0answers
11 views

ERROR: vars is not a legal parameter in an Ansible task or handler

I am getting this error while executing my playbook. My main.yml - - name: Main Playbook Started hosts: remotehost connection: local roles: - role: tomcat tags: - tomcat /...
0
votes
2answers
43 views

Ansible “Yes” and “No” possibilites for installation

is possible to prompt user with "Yes" and "No" question? I am sure there it is, but I need it to install package on "yes" answer and with "no" just skip package. How to effectively do it? Thanks.
0
votes
1answer
52 views

How to send password with special characters from ansible to Python script?

I am invoking a python script from ansible playbook. While invoking I am passing the credentials to the python script as arguments. The password has some special characters. But in Python script, I ...
0
votes
1answer
54 views

Ansible Unable Non Root User Unable to Install using APT

I create a new user using ansible called nginx, nginx is part of the sudo group a, but when I try to do an apt install with this user I get the below error : FAILED! => {"changed": false, "msg": "...
0
votes
2answers
103 views

Invoking Python Script through Ansible Playbook and running it in background- Through Ansible Tower

Here I am trying to invoke a python script through ansible playbook. When I run the playbook containing below mentioned code, it is successfully invoking the script. But ansible script continues to ...
0
votes
0answers
43 views

Ansible: vmware_guest: VM Deployment

I'm currently trying to figure out how best to approach a situation where a vCenter has one or more Datacenters with the same name but in different Folder Locations. Because of this I'm unable to ...
0
votes
2answers
89 views

Unable to connect to Ansible via SSH

I create a host file with the below content [web] 167.172.xxx.xxx I have a user root and dojo360 on the web server and the public key has also been added to authorized_keys file. When I run the ...
0
votes
0answers
11 views

Hhow to make it authoritatively change position in the "stdout_lines [] to run a task

my name is Esteban and I would like you to help me solve this problem in Ansible. It turns out that I want to know how I can make my program change position automatically so that it executes a task. ...
0
votes
2answers
103 views

Ansible: How to Remove /etc/hosts entries on the remote server using Ansible playbook. I need only the default entries to be present

How to Remove /etc/hosts entries on the remote server using Ansible playbook. I need only the default entries to be present. I need only below entries to be present: 127.0.0.1 localhost localhost....
0
votes
1answer
25 views

Using “echo” in a pipe in ansible's shell module

I'm using the shell module: - name: trust gpg key become: true shell: echo -e '5\ny\n' | gpg --homedir /root/.gnupg --command-fd 0 --edit-key 1401d4d21e93 trust But this complains with gpg: ...
0
votes
0answers
33 views

Permission Denied error in Ansible while connecting to Remote Host

I am writing a playbook where i am trying to connect to one of my remote servers and getting the below error. My Yaml looks like below where I am passing --ask-become-pass as argument and entering the ...
0
votes
1answer
93 views

Ansible is it possible to use variable in template src

In ansible we are trying to access different templates based on variable. We have following template files like: templates app1.conf.j2 app2.conf.j2 app3.conf.j2 taks app.yml In ...
1
vote
1answer
75 views

ansible only run one of a with_item list limited by tags

Im importing a usercreate role into an application role for the purpose of installing the application user only from the usercreate role. I'm having problems limiting the usercreate role to only ...
1
vote
1answer
686 views

-bash: ansible-playbook: command not found

Fresh Fedora Server Netinstall. Updated. Installed only Git and Ansible latest versions from standard repo. Want to execute Ansible against it's own host (localhost) to set up its host itself (not ...
1
vote
2answers
161 views

ansible display file content to stdout

I'm using ansible 2.9.3 and I'm having trouble trying to display the content of a file from the target machine, this is my playbook : - name: Display content of resolv.conf hosts: jenkins tasks:...
1
vote
1answer
26 views

use Regex to get a string from a file

I'm a beginner with regex Basically what I have on the line of my file is: grails.plugin.springsecurity.xxx.dtes.sp.file = '/home/share/9WR/config/application1-t-sp.html' // for unix file based ...
2
votes
2answers
150 views

Print Ansible header before executing a long running task

Context I have an Ansible playbook that includes a very long task, up to one hour. Very simplified, it looks like: - hosts: localhost tasks: - name: Short task debug: msg: "I'm quick!"...
0
votes
2answers
959 views

Installing Multiple Packages on Multiple OS with Ansible

I have a host with 2 servers: one has CentOS and the other Ubuntu installed. I decided to install apache, nginx and php-fpm on both servers and wrote 3 playbooks. ubuntu.yml (/home/ansible/playbook):...
0
votes
1answer
46 views

How to use ansible to assign multiple existing users to a new group

I created a new group in OS. Now I want to assign 5 or more existing users to that group using ansible. I believe I could do this for single user. --- - name: add user to a group become: 'yes' ...
0
votes
2answers
204 views

How to isolate ansible output based on key

I am trying to isolate the output of the ansible playbook however it says "output.stdout": "VARIABLE IS NOT DEFINED!" My playbook code is: --- - hosts: localhost tasks: - name: Register ...
0
votes
1answer
172 views

Ansible playbook - variable concat in conditional

I have a working task to migrate (copy) a specific part of my homedir (second to last line is the important one): - name: "Migrate my-pc module home files" copy: src: "{{ migration_source_path }...
0
votes
0answers
54 views

Combining Azure Blueprints and Ansible

I'm planning on implementing an Azure project using Ansible and already managed to create some resources using a playbook. Now my question is: how do I combine Azure Blueprints with Ansible? Or does ...
0
votes
0answers
93 views

Ansible dynamic inventory to return both public and private ip of instance simultaneously

I have created infrastructure on AWS using Terraform. My infrastructure includes two VPC's, two public and two private subnets, each on other AZ. I have three instances up, one in public subnet with ...
0
votes
1answer
290 views

Ansible register variable to log file

I'm trying to run the a yum list updates command and output the result to a file on the local server. This would be scaled out to run on multiple servers. I have found the local_action module, however ...
1
vote
1answer
45 views

How to enumerate hostvars into a role setting in Ansible

So I'm using a role to configure my postgresql server. That tole has a way of specifying server users & databases, like so: postgresql_users: - name: baz My hosts.yaml: all: hosts: ...
1
vote
1answer
91 views

ansible task with tag 'never' inside role executed when the role is executed using another tag

I have a playbook which has three roles netdata, netdata_master, netdata_slaves: --- - hosts: netdata_master become: yes roles: - role: netdata - role: netdata_master tags: ['...
0
votes
1answer
878 views

Ansible gives me an error during execution of some playbooks

I use Ansible 2.9.2 on Ubuntu Server 18.04 + Python 3.6.9. Here is a simple Ansible project: https://github.com/770715/ansible.git If I run: ansible-playbook -i aws_ec2.yml add-ssh-keys.yml it ...
0
votes
2answers
915 views

ansible delegate_to doesn't use inventory host?

I'm attempting to use ansible synchronize to copy files between two remotes. My playbook looks like: - hosts: newserver tasks: - name: Copy images from old to new synchronize: ...
0
votes
1answer
49 views

How in Ansible use “in” for nested lists in a variable

I'm trying to build a condition for launching a role so that it runs only on servers whose variable matches the values from the list in another variable. How does it work: Var: architecture: ...
0
votes
2answers
590 views

Ansible playbook: url returns 404 with apt-key module while working manually (browser or wget)

Can anyone tell me why does this old key work for me with the apt-key module of the ansible-playbook and this new key doesn't (404)? The initial key worked for a short while (when I was developing ...
0
votes
2answers
479 views

Using ansible check ssh passwdless login, if not working, copy pub key to the remote host

I am learning ansible, this is my playbook, --- - name: Check passwdless login #hosts: stage-servers hosts: Testing-Server gather_facts: False tasks: - name: check ssh to remote hosts ...
0
votes
1answer
119 views

Ansible create files with user permissions in homedir of existing users

I have homedir of few users like that /home/user1 /home/user2 /home/user(n-1) I need ansible to get list of homedir and create file inside every homedir with correct permission. Now i have this ...
1
vote
2answers
126 views

Ansible: execute tasks.yml from playbook.yml

I searched a lot for exact the same thing that I wanted to do, but found nothing. So, I'm here to ask: I have a playbook.yml, where defined some tasks. The first task of that playbook is checking ...
5
votes
1answer
1k views

The value True (type bool) in a string field was converted to u'True' (type string)

I'm trying to follow parameters/examples, yet running into following WARNING message while executing Ansible'playbook: TASK [apt (pre)] ****************************************************************...
0
votes
1answer
752 views

Using variables in ansible script after fetching from csv files inside a loop

I am new to Ansible. I want to know how I can read an excel or csv file inside Ansible, store the information in variables and work with those variables. Actually I want to create VMs. I will use the ...
2
votes
1answer
509 views

Ansible - Proper method for handling roles, tasks, dependencies?

Ansible - Proper method for handling roles, tasks, dependencies ? Related to How to keep ansible role from running multiple times when listed as a dependency? This is a long post/question. TL;DR - ...
1
vote
1answer
112 views

Ansible Playbook Task Gets Skipped

I have 3 aws ec2 instances, 2 are ubuntu and 1 amazon linux 2. I have configured the master slave setup and works fine. Master Instance: NAME="Ubuntu" VERSION="18.04.3 LTS (Bionic Beaver)" ID=ubuntu ...
0
votes
0answers
71 views

How can I use Ansible to start a Google Cloud Compute Engine VM which is in stopped mode?

I would like to start a stopped VM from Ansible. Is this possible? I have attempted to write a task per the gcp_compute_instance module docs - relevant lines: name: start VM gcp_compute_instance: ...
0
votes
2answers
30 views

converting two lists into a specific dictionary so it can be sorted

I want to convert the following lists: rtt: [38,1,97] site: ["A","B","C"] into a dictionary like: dict: [ {'rtt':38, 'site':'A'},{'rtt':1, 'site':'B'},{'rtt':97,'site':'C'}] so i can sort it on ...
0
votes
1answer
50 views

“map” function in ansible changes original sequence of list

I need to extract a variable from an inventory: [all] 1.1.1.1 site=A 2.2.2.2 site=B 3.3.3.3 site=C When i use: sites: "{{ hostvars | map('extract',hostvars,'site') | list}}" the resulting list is: ...
0
votes
1answer
112 views

combine multiple dictionaries with a list into one for looping in ansible

I have two dictionaries per host in ansible: { "rtt": [38,1,97] } { "site": ["A","B","C"] } I want to now loop of a list or items, where i can reference the individual items like: debug: msg: "{{...

1
2 3 4 5 6