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.

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

Ansible orchestration for ufw with ufw --force enable

I deploy an Ansible playbook to some debian:stable machines aiming to update package index cache, install ufw and setup it in the Ansible architecture-agnostic and version-agnostic way. - name: ...
0
votes
1answer
847 views

What does cache=yes mean in apt: update_cache=yes in Ansible?

I know that apt update updates existing package-indexes on a supporting distro but not upgrading installed-packages (utilities) that were being installed based on these package-indexes (as apt upgrade ...
2
votes
1answer
945 views

Ansible command returns change instead of success

I'm learning ansible and encountered a situation which is not clear. Running the following module command the result is a 'Changed'. ansible agent.example.com -i inventory -m copy -a 'content="Node ...
1
vote
1answer
384 views

Ansible - Add a word to a specific line in a specific part of that line

I want to add the word "nodev" to the line that contain /home in /etc/fstab file here's the file before UUID=2ea6e2e5-d902-4289-b516-40c175cd481b / ext3 defaults 1 1 ...
1
vote
2answers
202 views

read-verification alternative (two prompts and if-then comparison alternative)

I am trying to create a small script for creating simple, all-default Apache virtual host files (it should be used any time I establish a new web application). This script prompts me for the domain....
1
vote
2answers
166 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
478 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
1k 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 ...
1
vote
0answers
123 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
1k 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 ...
4
votes
1answer
547 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
641 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
42 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
302 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
976 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
2k 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
2k 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
286 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
1k 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
4k 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 ...
2
votes
2answers
68 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
941 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 ...
1
vote
0answers
89 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
7k 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
331 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
257 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
978 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@...
2
votes
1answer
6k 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
322 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
536 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
304 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
852 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 ...
4
votes
1answer
2k 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
29 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
130 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
3k 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
81 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
883 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
143 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
294 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
2k 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 "...
1
vote
0answers
181 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
763 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
248 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
5k 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 ...
3
votes
1answer
11k 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
6k 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
2k 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
1k 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
4k 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)?" ...