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
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
191 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
364 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
114 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
432 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
171 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
832 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
494 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
249 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
207 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 ...
3
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
591 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
594 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
662 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
626 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
580 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
786 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
105 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
915 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
195 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
391 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
710 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
593 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
357 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 ...
6
votes
1answer
534 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
389 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')...
2
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
928 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
590 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 ...
3
votes
1answer
5k views

The destination directory (/etc) is not writable by the current user on ansible

I am using Ansible-2.0 on linux machine and I wish to do change DNS on remote machine using ansible as below: --- # tasks file for test - name: Change dns become: yes become_user: admin ...
19
votes
1answer
19k views

ansible extract without first directory

When extracting a tar.gz file in ansible I end up with a first directory - name: Extract archive unarchive: src=file.tar.gz dest=/foo/bar which results in /foo/bar/bar-version-...
-1
votes
1answer
599 views

File not copy to remote pc using ansible

I am using ansible-2.0 on linux machine and create the ansible-galaxy, on it created the dns.yml file which replace the /etc/resolv.conf on remote machine but it's not working. Ansible status showing ...
0
votes
1answer
438 views

SSH startup script fails with -t option

I'm wondering about the SSH -t option. When I try to start a Tomcat server like this: ssh user@example.com -t '~/tomcat/bin/startup.sh' then Tomcat will not be started, eventhough the startup ...
1
vote
1answer
621 views

Ansible triggering oom-killer

Running ArchLinux uname -a: Linux localhost 4.7.2-1-ARCH #1 SMP PREEMPT Sat Aug 20 23:02:56 CEST 2016 x86_64 GNU/Linux 16gb of RAM 14gb swap When I run big ansible jobs, it triggers my oom-killer....
1
vote
0answers
102 views

Detect if password is expired from ssh

How to catch expired (own) password from ssh, from non-root account ? Expect is not installed on target servers. I need to catch two states with single command: password is expired → when you login, ...
4
votes
0answers
956 views

Ansible play for creating user not setting password

Try to set a password randomly and create user with it: vars: users: - username: myuser password: "{{ 99999999999999 | random | to_uuid }}" role: - name : Add user accounts user: name: ...
2
votes
1answer
2k views

Can I view tasks that will be run by ansible-playbook?

Can I review tasks that would be run by ansible-playbook? ansible-playbook --check does not list all tasks. Tasks which depend on previous tasks being performed may fail, causing ansible to stop ...
1
vote
2answers
1k views

Use of 'local machine's IP' in iptables rule?

I have written port-forwarding iptables rules that I plan to roll-out to several machines in an automated way using Ansible. However, the POSTROUTING chain rule requires a modification of the source ...