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
1
vote
0answers
189 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
854 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
262 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
7k 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 ...
2
votes
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
5k 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)?" ...
2
votes
1answer
3k 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 ...
0
votes
1answer
206 views

separator value from fact variable in ansible

I get ssh connection from fact variable in fact. my code in template (get-ip.j2): nod= {{ ansible_env.SSH_CONNECTION }} my output is : nod= 192.168.231.115 55414 192.168.231.91 22 Now, how can ...
0
votes
1answer
373 views

Unable to create EC2 instance using Ansible

- name: Create VPC ec2_vpc_net: name: arunvpc cidr_block: 10.4.0.0/16 region: ap-northeast-1 aws_access_key: "{{ aws_access_key }}" aws_secret_key: "{{ aws_secret_key }}" ...
0
votes
3answers
7k views

Ansible array variable

I have a template file config.j2. {% for host in groups['dbs'] %} ips= {{ hostvars[host].ansible_default_ipv4.address }} {% endfor %} My output is: ips= 192.168.231.91 ips= 192.168.231.92 ...
0
votes
1answer
123 views

playbook giving syntax error

i am running this playbook, but its failing at last task. running this from ubuntu host,, --- - hosts: all become: yes tasks: - name: Copy certificate files. copy: src: "{{ ...
1
vote
2answers
3k views

sshpass not functioning in alpine linux

When I install sshpass on alpine linux it will install and the doc will show up if you run it without arguments, but using any argument (valid or invalid) returns sshpass: Failed to run command: No ...
2
votes
1answer
461 views

Ansible shell module empty response

When i execute the command "who am i" using ansible's shell module, i get an empty response, i can't figure out why ? hosts: server1 remote_user: devops become: true tasks: - name: print ...
1
vote
1answer
175 views

Ansible playbook syntax help from CLI

I would like to know all the ways i can get information about ansible from CLI. The help sources i know of are: 1- these "few" man pages: ansible (1) ansible-config (1) ansible-...
0
votes
1answer
859 views

Ansible fails after changing ansible_python_interpreter

After changing the default python path ansible cannot run or load any python library { "changed":false, "failed":true, "module_stderr":"Shared connection to x.x.x.x closed.\r\n", "...
2
votes
1answer
538 views

ansible | remove link | advanced

I want to achieve the following - in a directory 'sites-enabled' to have only the symlinks present that are defined in a list {{ sites_enabled }} Specifically the difficulty is with - how can I make ...
0
votes
2answers
253 views

Installing nagios 3.5.1 with epel repo

I am trying to install nagios-core 3.5.1 with yum using epel repo. I am facing problems since the old versions of nagios has been removed from epel-repo. The latest epel-repo is coming with nagios 4.3....
1
vote
1answer
212 views

Vagrantfile setup to allow Ansible to SSH in

I have a vagrantfile from a book about Ansible for Devops. The issue I have is that I can SSH into the servers but Ansible cannot. Here is my vagrantfile; # -*- mode: ruby -*- # vi: set ft=ruby ...
5
votes
2answers
3k views

Can I automatically accept MS SQL license terms while installing the yum package?

I am using Ansible to provision MS SQL Server 2017 to a CentOS 7.4 box. I first went through this guide via command line and it works, but my end goal is to "Ansible-ize" it. However, when I get to ...
0
votes
1answer
640 views

Ansible: core modules are missing

I willing to get a list of variables for the host using ansible all -m system and keep getting an error: The module system was not found in configured module paths. Additionally, core modules are ...
0
votes
1answer
2k views

Ansible playbook - to change the line in configuration file

I need to write a playbook to replace the line locking_dir = "/var/lock/lvm" to locking_dir = "/run/lock" in /etc/lvm/lvm.conf using ansible /root # cat /etc/lvm/lvm.conf | grep locking_dir | grep -v ...
0
votes
1answer
606 views

How to make playbook idempotent with raw module?

I have servers without python2 installed by default (the target servers are mainly under Alpine Linux) and i use the playbook below to fix that. - hosts: all become: yes remote_user: root ...
0
votes
1answer
715 views

Can't install packages on remote nodes via Ansible

I have installed and configured Ansible. My environment is as below: Control Machine is Ubuntu 14.04 Nodes are Centos 7 Below is my hosts file: # cat /etc/hosts 127.0.0.1 localhost 192.168.2.100 ...
2
votes
1answer
652 views

What is the best way to share the SSH authentication socket with another user?

I'm using Ansible for setting up a remote server and I'm using SSH agent forwarding to git clone a repository from bitbucket.org to use my local SSH key, because I'm using sudo I'm preserving the ...
0
votes
1answer
1k views

removing particular string from a specific tag in a file using ansible

I need to delete a particular string from particular tag in a file using ansible, as below you can see from [pipeline:public_api] I need to remove admin_token_auth [pipeline:public_api] ...
2
votes
1answer
604 views

inserting data into a particular section of a configuration file with ansible

I have come across a peculiar issue while using ansible. The problem is very strange and dangerous. I have a written a code to insert data in a particular section of a file i.e to add line after [...
0
votes
2answers
814 views

host_vars not working in Ansible

I need to use host_vars in my ansible file to install a package on remote host, i am trying to pull a variable by the name package from host_vars dir in which a file ansi2 reside which is the ...
1
vote
1answer
108 views

Ansible - Junos

I am trying to use ansible with Junos devices, following this doc: http://docs.ansible.com/ansible/junos_command_module.html I have created the this playbook: - name: run a set of commands ...
0
votes
2answers
2k views

include_vars what it actually means

i basically want to take dynamic information from my remote host whether in it is redhat or debian, and accordingly execute particular file which would be installing http packages based on os flavour. ...
0
votes
1answer
997 views

Ansible shell module problem

i need to clear the contents of a file on remote hosts using shell module in ansible but unable to do so --- - hosts: ansi1 become: yes gather_facts: no tasks: - name: checking shell ...
1
vote
1answer
199 views

ansible role: Why do I have to set user.email in etckeeper?

I wrote a ansible role to automate installing etckeeper. I discover that git will complain if I haven't configured user.email. In some circumstances, git commits will fail. This includes automatic ...
8
votes
2answers
1k views

Whenever ansible makes changes to sshd in CentOS7 a random future play cannot connect

This has been an irritating enough problem now that I thought I would finally ask the community at large what a possible solution might be. It's even more irritating that I seem to be the only one ...
1
vote
1answer
414 views

Automation of Oracle XE installation with ansible and vagrant - Oracle environment variables not correctly visible?

I am currently trying to automate Oracle Database XE using ansible playbook. Everything with the installation seems to be fine, except for the step in which environment variables for Oracle are set: ...
1
vote
1answer
8k views

Taking register value and using it later as variable

I want to make the dynamic assigned ip to vm permanent by adding it to its ifcfg-eth0 file,, im having trouble at using the register: eth0 value which is the actual ip address and putting it in last ...
0
votes
2answers
729 views

Blockinfile not working in ansible

I need to enter a block of data on a remote host using ansible, i have tried "blockinfile" but was unsuccessful.. But when i run the same thing on omy local hosts it works fine dont know why --- ...
-1
votes
1answer
611 views

unable to execute ansible play on remote host

I'm trying to run multiple shell commands in ansible on a remote host, but failing miserably: - name: Mkdir on server and copy packages locally shell: | mkdir /root/vdbench cd /...
1
vote
2answers
1k views

Is it possible to add 2 diff cmd in ad-hoc ansible cmd?

I need to run 2 diff cmd in ad-hoc mode in ansible ?? is it possible 1] hostname 2] df -h # ansible example -s -a "hostname && df -h" Error ```[root@ansi1 ansible]# ansible example -s -...
2
votes
1answer
368 views

Ansible Task Creates option issue

I want to write an Ansible playbook to install a package only if a particular is not present, so when the /tmp/hosted file present installation should not proceed, but it's failing: --- - hosts: all ...
7
votes
1answer
555 views

How do I open a file with ansible-vault edit from inside vim?

Usually, when I want to open a file encrypted by ansible-vault for editing, I just run ansible-vault edit <filename> - this decrypts the file to a temporary file and opens it for editing. ...
1
vote
0answers
2k views

Unable to execute Curl request from Ansible playbook script [closed]

I am making a simple script that will run on the Ansible node, and notify me via Slack api if upgrades are available. If I execute script in my hosts (all Debian based), I receive notification in the ...
3
votes
1answer
401 views

with CentOS 6.x minimal install I cannot start iptables

I'm currently working on a Ansible playbook that attempts to install and start the iptables firewall on a CentOS 6.8 minimal install. I'm doing the following in Ansible. ### sets up FW pkgs - name: ...
1
vote
4answers
4k views

Copy files to aws s3 bucket using Ansible

My plan is to copy file from ec2 to s3 bucket using ansible, Here I've make playbook but getting some error: copy2s3.yml --- - name: Copy to s3 s3: aws_access_key: "{{ lookup('env','aws_key')...
3
votes
1answer
7k views

How to ignore a particular output error string in Ansible and consider successful

I'm trying to ignore a particular error message in playbook output is having below error message. fatal: [192.168.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "Sending passwords in ...
4
votes
1answer
942 views

How do I install jdk on SUSE Linux with ansible?

I need to install java on one of my VMs running SUSE Linux using ansible. Below is the playbook code I am using: - name: Download Java become_user: "{{user}}" command: "wget -q -O {{java_archive}...
1
vote
1answer
1k views

How to modify sudoers file with ansible?

We have a sudoers file in /etc/sudoers.d/ops (on 10 servers). Sometimes we need to add multiple users and Cmnd_Alias to that file. How can we automate this with an ansible playbook? Our sudoers file:...
0
votes
0answers
600 views

argument not work on expect through command line

Here I have creating script which execute the ansible-playbook, After the execute script which ask the Sudo password which one I have to send(sudo password) though expect and send but getting below ...
4
votes
1answer
2k views

read a file and execute each line as command using ansible

I want to write a playbook for following scenario: reads a text file which has linux commands written it, executes them one by one, aborts if any command fails to execute, and if I correct the command ...