Stack Exchange Network

Stack Exchange network consists of 175 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.

23
votes
1answer
20k views

Proper syntax for ansible symlink

What is the proper syntax for creating symlinks using ansible? I'm creating a Vagrant virtual environment and running ansible as my provisioner. Everything works fine up until I try to symlink to my ...
21
votes
3answers
54k views

List ALL Ansible variables for a host or group with an ad hoc command?

Ansible variables come from a variety of sources. It is for example possible to provide host_vars and group_vars by creating YAML files in a subfolder named host_vars and group_vars respectively of ...
18
votes
1answer
16k 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-...
12
votes
1answer
67k views

Ansible use inventory_hostname or ansible_hostname in task name

I am writing a rolling upgrade playbook and would like to print out the hostname of current host been upgraded. I put inventory_hostname and ansible_hostname in task names but that did not work - ...
8
votes
4answers
872 views

Is there a distro-agnostic configuration management software?

I don't want to label myself to specific configuration-manager modules like Ansible's apt module or yum module. Is there a distro-agnostic configuration management software, or at least one with ...
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 ...
7
votes
1answer
14k views

How can install specific version of ansible?

How can I install a specific version of Ansible, using Yum or another method? When I try to install version 2.0 it says No package 2.0 available. I checked the epel repo. There are only two rpms, ...
7
votes
2answers
25k views

How would I register a dynamically named variable in an Ansible task?

I'm trying to retrieve the group ID of two groups (syslog and utmp) by name using an Ansible task. For testing purposes I have created a playbook to retrieve the information from the Ansible host ...
7
votes
1answer
505 views

Configuration management via versioned packages

For the hosts we manage, my boss has a vision of configuration management via versioned packages (in our particular case, fpm-built debian packages). This is to make: host deployment easier easier to ...
6
votes
1answer
481 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. ...
5
votes
2answers
11k views

Ansible failed_when only print customized error message

I am writing a simple Ansible playbook to run RHEL leap second detector on Linux boxes with mixed distribution. here is the playbook --- - hosts: Linux vars_files: - ../group_vars/Linux.yml ...
4
votes
1answer
17k views

Unarchiving a downloaded tarball with Ansible

I'm trying to get WordPress downloaded and installed via Ansible and I can't seem to figure out what I'm doing wrong here. First I download via the get_url module then I attempt to use the unarchive ...
4
votes
2answers
21k views

Add user and set password using Ansible

I have created an Ansible playbook to create user and set password. But it is giving me an error ERROR: password is not a legal parameter of an Ansible Play --- - hosts: all user: root vars: ...
4
votes
1answer
3k 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 ...
4
votes
1answer
371 views

Turn off color in bash for logs

I am running Ansible on multiple machines and redirecting the output to a file, say log-$(date), which is mailed to me every day. The output file has multiple text colors, how to turn them off? ...
4
votes
1answer
353 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: ...
4
votes
1answer
4k 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 ...
4
votes
1answer
362 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 ...
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 ...
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 ...
4
votes
1answer
850 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}...
4
votes
0answers
919 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: ...
3
votes
2answers
2k 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 ...
3
votes
1answer
907 views

What Command Line tools to connect from Unix to remote Windows?

I need to make some scripts for connecting from a Unix server to several Windows stations for automating file transfers. GUI is not needed and I can't install any additional software into Windows ...
3
votes
1answer
334 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 ...
3
votes
0answers
669 views

using ansible via vpn

I have a set of hosts that I can only access via openVPN (one VPN per host or group of hosts). ssh is only available after connected to the VPN. Is there any way to automatically bring up the VPN ...
3
votes
0answers
2k views

start-stop-daemon, services, environment variables, and ansible

So, I have a Java program that runs Ansible. I'd like to run this program as a service. I've written a service script in /etc/init.d that uses start-stop-daemon to run/stop the Java program. I've run ...
2
votes
3answers
3k views

Is it possible to start administering a linux box via Ansible with just the root account and its password?

I recently rented a Linux box and I intend to provision it using Ansible. I'd like to use Ansible as early as possible in the process. At this stage I only have a root account and the corresponding ...
2
votes
1answer
517 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 [...
2
votes
1answer
4k views

In Ansible dynamic inventory JSON, can I “render” hostvars based on the hostname?

The Ansible documentation gives an example here on how to return an inventory in JSON format: { "databases" : { "hosts" : [ "host1.example.com", "host2.example.com" ], "vars" ...
2
votes
2answers
161 views

How to enable or disable Apache modules in a distro-agnostic way?

I usually work with Debian/Ubuntu as a basis for Apache and recently learned that commands like a2enmod MOD or a2dismod MOD are Debian-specific. Is there a global / distro-agnostic way (maybe with ...
2
votes
1answer
98 views

Is it a best practice to use Ansible-Galaxy roles in playbooks instead ansible-modules in playbooks? [closed]

I have an Ansible playbook for establishing LAMP environments on remote machines. Part of this playbook deals with installing Composer: - name: Install Composer get_url: url: https://...
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 ...
2
votes
1answer
9k 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: ...
2
votes
1answer
565 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 ...
2
votes
1answer
102 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 ...
2
votes
1answer
4k views

How to Bind Mount /var/tmp to /tmp using Ansible and to CIS standards

I am hardening a centos6.7 VM to CIS benchmark standards. I am automating as much as I can using Ansible. The hardening document I am using is (page 12-13): https://benchmarks.cisecurity.org/tools2/...
2
votes
1answer
4k views

Bash script and yml file output

I'm trying to catch the stdout of a script to a file, and at the same time have it display its ongoing summary: ./RUN host-names ANSIBLE.yml 2>&1 | tee out.txt What this does is that it ...
2
votes
1answer
127 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 ...
2
votes
1answer
384 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 ...
2
votes
1answer
2k views

Configure Ansible to write logs to a different file on managed servers

I would like to know if there is a way to configure Ansible to have its own log files instead of writing to /var/log/messages on RHEL server.
2
votes
1answer
403 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 ...
2
votes
2answers
457 views

Ansible resumable plays [e.g. with site.retry]?

Using ansible often relies on a property called "idempotence". If you apply a role a second time, it's expected to have the same result. E.g. it won't add a second copy of the same line in a config ...
2
votes
1answer
257 views

Replace deployment scripts with ansible-pull

To deploy new servers I use a master script (in bash) which downloads from a repository another script. That script then configures the servers and the services I want. The master script is always the ...
1
vote
3answers
355 views

What's the advantage of mere Ansible on mere shell-scripting if one doesn't use communally-maintained Ansible-Galaxy roles? [closed]

I establish a LAMP with a few extras on a remote Debian machine with a similar shell (Bash) script: #/bin/bash apt update -y apt upgrade ufw sshguard unattended-upgrades wget curl git zip unzip tree ...
1
vote
2answers
148 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
2answers
4k 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 ...
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
2answers
191 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
2k 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 ...