Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ansible]

Ansible is an automation tool ("IT orchestration engine", per the company web site) for the deployment and configuration of applications and systems.

0
votes
0answers
26 views

When adding a new hard disk to a running VM, do I still need to scan for new SCSI devices?

End Goal To automate the addition/extension/formatting of a new disk onto a running Linux host using vSphere and Ansible. Dilemma I'm not a huge fan of writing such automation when I don't fully ...
1
vote
2answers
80 views

Using Ansible inside Bash

I use Ubuntu 18.04 with Ansible installed this way: apt-get update -y install software-properties-common apt-add-repository ppa:ansible/ansible apt install ansible I also have a small Bash script I ...
1
vote
1answer
19 views

Ansible, docker_container and depends_on

I am using ansible and docker_container module. But when I start my playbook, I have error like: "'depends_on' is not a valid attribute for a Task" This is my playbook: - name: Docker-compose ...
1
vote
2answers
40 views

Ansible Playbook: Get value from variable

I'm writing my first ansible playbook right now. That's what I have so far. --- - hosts: kolumbus become: yes tasks: - name: Copy RPM copy: src: "{{ item }}" dest: /tmp ...
0
votes
0answers
34 views

not run expect script in ansible

my script is : #!/usr/bin/expect set timeout 1 spawn /etc/init.d/oracleasm configure expect "Default user to own the driver interface []:\r" send -- "grid\r" expect "Default group to own the ...
0
votes
2answers
13 views

How do i store a variable value to a file in new lines on ansible

I would like to store the variable value to a file in new lines format. - set_fact: linked_dirs: "{{ linked_dirs.stdout_lines | select('search',nfs_server) | list }}" - debug: var=linked_dirs ...
0
votes
0answers
31 views

How do I map the fields from the stdout_lines in ansible?

I would like to map the fields from the output of the "std.out_lines". Below is my output. > ok: [rchdata01] => { > "msg": [ > "host_name criticality server_loc ...
3
votes
1answer
92 views

ansible.cfg become_ask_pass not working

I am using Ansible 2.5.1., and I do not want to use the flag -K all the time (I think it will be deprecated soon). I know there is a directive of become_ask_pass in the ansible.cfg file. I set this ...
0
votes
1answer
47 views

How to specify range to iterate through an array in ansible

I want to remove an application on a remote node using ansible. Below is my playbook. How do i provide a range to the uninstall task to repeat till no packages are left. --- hosts: all tasks:...
0
votes
1answer
19 views

ansible block of code

I need to create an xml formated file in ansible. The file contains <> and spaces. When I run the playbook without the <> or any white spaces between lines in it, the playbook creates the ...
0
votes
2answers
48 views

need to list the item from facts output

I need to save the target host's IP addresses to a file using set_fact. Below is my playbook, but it's giving output as a list. hosts: all tasks: - set_fact: data: "{{ ...
-1
votes
1answer
333 views

replace specific line in file with ansible [closed]

I know how to replace strings in the file with the ansible replace module. What I am looking at is replacing a specific line. I have a file that has the same string in several places and I only want ...
0
votes
2answers
141 views

Ansible: return status of the last task

I'm using this command to have a return from tasks in ansible. To see if they are successful or not. This is a example of my code in a playbook: - name: Install JDK8 shell: cd /tmp/install/ &&...
0
votes
3answers
151 views

simulate enter key in Ansible

I am trying to create a playbook to run the mysql_secure_installation command. This command ask several questions. I am using pexpect, but not sure how to simulate an "enter" The first question it ...
0
votes
2answers
26 views

Find in Ansible and Save to a file

I want to save the result of find into the file with an Ansible play. - name: Find / -name "postgresql" find: paths: /var/log patterns: 'postgresql' The result of above will be saved into ...
0
votes
1answer
73 views

How to pass prompt in ansible?

I am trying to pass a prompt y in ansible when it executes the below command. When i do manually on server it asks for a prompt. How should i do it with ansible using shell module.Please help with ...
4
votes
1answer
702 views

Terminate and disable/remove unattended upgrade before command returns

I'm having an issue here where I try to automate a setup with Ansible. Some of the steps require interaction with apt, but occasionally I get an error because unattended-upgrade kicked off and locked ...
0
votes
0answers
39 views

The url-path name must be set to the file path name or the directory path name

So I need to make sure that the url-path is set to the file path from a httpd.conf file directive path. So I have a stig and It states If the directive uses a URL-path name that is different than the ...
1
vote
2answers
50 views

Using a if/else statement in shell for netsat

My goal is to ensure that email connections are limited to outbound only So I have two shell commands one is netstat -an | grep ':25' | grep -v '127.0.0.1' | wc -l which prints out 1 The command ...
-1
votes
1answer
164 views

Ansible Playbook syntax check issue

i have below detail in /etc/ansible/hosts [dev] 10.13.212.32 and i am able ping this hosts as below: # ansible dev -m ping Output: [root@localhost ~]# ansible dev -m ping 10.13.212.32 | SUCCESS ...
0
votes
0answers
31 views

Specify destination interface firewalld rich rules

I'd like to specify the destination interface for a firewalld rich rule using an option similar to -i with iptables. -i: specifies name of an interface via which a packet was received. I'm aware of ...
1
vote
0answers
41 views

Ansible: failed to ping a linux container

Continuig with my ansible learning, I already fixed how to Ansible: How to parse an inventory source but now I ran into a new problem. He executes the following 2 commands (but im not sure if he does ...
1
vote
2answers
794 views

Ansible: How to parse an inventory source

I'm following an Ansible tutorial I got from Packt, I reached this part where I've created 3 Ubuntu containers (lxc) and got them up and running. I'm also able to login to each of them. I've ...
0
votes
4answers
201 views

Best practice DNS (resolving IP to hostname in LAN)?

Recently I've created my own thin client operating system (Xubuntu based, so basically Linux yes) that will run across our thin clients. Currently I'm testing the OS in my test environment, but I've ...
-1
votes
1answer
97 views

ansible and continue the script with expect tools

My expect script: #!/usr/bin/expect -f set timeout 1 spawn /opt/install.sh expect "\[input\] Are you installing the application at the central data center? \[yes/no default: yes\]? \[yes\]\r" ...
0
votes
1answer
239 views

ansible and expect problem

I want to use expect tools in bash script by ansible. first, step my shell script. Checking for $JAVA_HOME variable. I set $JAVA_HOME but in Ansible, I get an error. My env for $JAVA_HOME: [root@...
1
vote
1answer
1k views

When I use ansible module expect, I get this msg: The pexpect python module is required

Some code from yml file: - name: --- run /opt/installer/bin/install.sh --- expect: command: /opt/installer/bin/install.sh responses: 'Are you installing the application at the ...
0
votes
1answer
201 views

Concatenate two commands with output on sam line Ansible shell command

I have this ansible command that is writing Docker container ip address and hostname to nginx hosts file which is running for more than 1 time. How can I join two commands and get ouput on same line ...
1
vote
1answer
202 views

Ansible copy module failure on Ubuntu 18.04 - “you may have been able to authenticate and did not have permissions on the target directory…”

I think I've used Ansible before, to control a Ubuntu 16.04 VM. I can definitely use this same task to successfully control a Debian 9 VM. However, with a Ubuntu 18.04 VM, it fails with "...
0
votes
1answer
212 views

How to automatically add IP addresses to Ansible host file

I am looking for a way to automate adding IP addresses to my Ansible host file when new Virtual machines are created instead of manually adding/removing them to the hosts file. I also want to be ...
1
vote
1answer
318 views

How to set ansible playbook to reboot servers

I want to be able to write one playbook to update all my servers in different environments - stage and prod. I do not want to reboot these servers every time there is an update to the kernel, I only ...
3
votes
1answer
797 views

Ansible - How to mark a tasks as success when it failed actually

We are using some pipelines to build servers using ansible and one of the task is to check if server is online (means a production server in inventory list by accident). We check the port 443 and ...
1
vote
0answers
26 views

Issue in finding modules to change directory service type of ESXI host to Active Directory using ansible

I am facing issue in finding modules to join ESXI host to Active Directory. I have comes across few modules like win_domain_membership like below. But it is not working out for ESXi host. Please help ...
0
votes
1answer
101 views

How to save the password for the next commands in the shell script?

When my script starts, the shell asks me for the password for the module apt-get, and then again for ansible, because it has the option --ask-get-pass. How do I enter the password only once for ...
1
vote
0answers
516 views

How to save ansible stdout.lines to a file is in list format

Need to save std.out lines to a file in delegated host using below playbook. I am able to save the data, but the saved data is in json format. I need this data as list format as like command output. -...
0
votes
1answer
27 views

Build Ansible inventory based on server variables [closed]

I want to build ansible inventory and assign hosts to respective groups based on the values gathered from Clients. Eg: Information of all the clients and their respective group will be pushed to ...
1
vote
2answers
545 views

Add new line to /etc/sudoers via ansible

I am trying to add new line to the /etc/sudoersfile via ansible. But it does not work what is the problem, Could you please help? I have tried visudo -c command in order to make sudoers file to ...
2
votes
1answer
86 views

Clarification on example from Ansible documentation needed

The lxd_container module for Ansible 2.5 contains this example: # An example for creating a Ubuntu container and install python - hosts: localhost connection: local tasks: - name: Create a ...
1
vote
1answer
211 views

executing linux script with options in expect

I am executing Linux script in expect mentioned as below. spawn "sh /opt/Avaya/CCR/util/CAT/cat.sh --iptfile=no" I am using ansible to execute above command . when I execute ansible-playbook ...
0
votes
3answers
878 views

Try to Get Single Row from Ansible Output

I am using ansible in order to read /etc/sudoers file to display which users have root permission on related server. This is the .sh file #!/bin/bash username=`sudo cat /etc/sudoers | grep "...
0
votes
0answers
68 views

Can't access gems after installing ruby and gems with ansible

I'm working on an Ansible script to install my standard working environment (Ruby on Rails). Ansible runs under sudo, and the gems that have been installed are only accessable under sudo too. If I ...
0
votes
1answer
238 views

ansible variable as environment variable

I try this - name: Install required packages shell: "apt-get instal linux-headers-{{ ansible_kernel }}" However getting this instead {"msg": "The task includes an option with an undefined ...
0
votes
0answers
150 views

ansible deprecated problem

I have ansible 2.4.2.x running and an inventory file which has "ansible_ssh_host etc." params.Normally ansible_ssh_host must be ansible_host as it is deprecated. deprecated . when I play with ...
0
votes
1answer
2k views

Ansible playbook fails when .ansible/tmp directory path changes

Essentially, what is going on here is that the user account that ansible is running under is present on both the control node, and the target client. However, on the target client, as part of the ...
2
votes
1answer
4k views

Ansible result.failed v.s. failed_when, result.changed v.s. changed_when etc

Ansible in 1.4 and later provides a way to specify this behavior as follows: - name: Fail task when the command error output prints FAILED command: /usr/bin/example-command -x -y -z register: ...
0
votes
1answer
2k views

for loop in jinja2 [closed]

Please explain to me how can I fix this problem? i have this file defaults/main.yml --- node1: ip: 1.1.1.1 node2: ip: 2.2.2.2 node3: ip: 3.3.3.3 Now, I want in template file ip.j2 by for loop ...
1
vote
3answers
795 views

Using /dev/stdin and a heredoc to pass a file from the command line

I'm curious about the theory behind how heredocs can be passed as a file to a command line utility. Recently, I discovered I can pass a file as heredoc. For example: awk '{ split($0, arr, " "); ...
1
vote
1answer
649 views

is it possible `cat` files role in ansible?

Is it possible cat files role in ansible? my defaults/main.yml is : --- srv1: webserver srv2: db srv3: dns I want cat defaults/main.yml and register in a variable.
1
vote
1answer
2k views

skip some task with prompt in ansible [closed]

How can I access to answer one prompt on another server? my hosts: [dbs] db1 db2 db3 I have one role and my tasks/main.yml is: - pause: prompt: "Do you want to install mysql (yes/no)?" ...
1
vote
1answer
2k views

How do you set up a confirmation prompt before running a playbook?

I want to install MariaDB after confirming user. I have a role and one simple task: - name: install MariaDB yum: name: MariaDB state: present or if I want to use include: MySQL.yml, if the user ...