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.

0
votes
2answers
29 views

Run shell command from Ansible

I have a shell script which just changes directory (here directory path is given). shell file #!/bin/bash p="dir/file/create" cd "$p" exec bash Ansible playbook --- - hosts: localhost ...
1
vote
3answers
6k views

ansible pass shell command result to variable

I stuck a bit with ansible and autogenerated id, I have multiple mysql master - slaves server for that I need to generate a server-id. my idea was to do something like this: - name: generate ...
0
votes
1answer
31 views

how to run playbooks in ansible parallel

site.yml --- - import_playbook: common.yml - import_playbook: redis.yml - import_playbook: riak.yml - import_playbook: webserver.yml - import_playbook: haproxy.yml I want to run these playbooks in ...
1
vote
2answers
25 views

It is possible to define an ansible.cfg file as the main config for only one role?

I would like to run the 'ssh' role without the become directive and run my others roles run with the become directive I decided to create an another config file ansible_ssh.cfg which not contains the ...
1
vote
1answer
39 views

Ansible dnf module: “MODULE FAILURE”

I am seeing the Ansible dnf module fail. But not reliably. When it does fail, it seems to succeed if I run Ansible again. My system is Fedora 29 Workstation. (More version information is shown ...
1
vote
2answers
323 views

When puppet, chef or ansible are simpler solutions than package manager?

I'm new to above deployment and configuration tools. I have typical need to install and upgrade on a target machine a customized and configured webserver, maybe reverse proxy, database, required ...
0
votes
1answer
36 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 ...
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....
0
votes
1answer
19 views

Ansible: Iterate over variables and run command if variable is defined

I want to set nameservers in /etc/resolv.conf using ansible. I basically want to set variables (DNS1, DNS2, DNS3). I only want to apply DNS# if it is defined. I have the following so far. # Run this ...
0
votes
0answers
34 views

ansible unarchive module not working as intented!

i am using ansible unarchive module,, cassandraDir = /opt/con/cassandra cassandra package = /tmp/apache-cassandra-3.7-bin.tar.gz I need to unzip the cassandra package in the "cassandraDir" ...
0
votes
1answer
35 views

Ansible modules copy/template errors for Linux 5 hosts using python26 ,python binding libselinux-python needed

We have some 50 odd linux 5 hosts, and to manage that we use ansible. Problem :- Ansible modules copy/template errors for Linux 5 hosts using python26 ,python binding libselinux-python needed ...
0
votes
1answer
40 views

how to use included variable from file with jinja2 template and with_items

I am having an error where the fields of my variable are not being detected when trying to build a configuration using a jinja2 template. This is to sync Linux repositories to yum and apt based ...
1
vote
4answers
3k 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')...
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 ...
0
votes
0answers
85 views

How can I prompt users while running a playbook?

My needs: Write a playbook which can install apache if the user wants to, while the playbook is running by typing yes or no. apache_prompt.yml hosts: slaves vars_prompt: - name: ...
0
votes
1answer
56 views

How to change the user after connecting to the jump host when using ProxyCommand

My normal flow is like: ssh jumphost sudo -iHu jump_user ssh target_user@targethost Do some task How to do this using ProxyCommand? I have tried: ssh target_user@target_host -o ProxyCommand="ssh ...
1
vote
1answer
37 views

If condition in ansible jinja2 template

Search keyword in "host_fqdn" variable. If the value has "lab.com" keyword in it, it should directly store the value to "host_fqdn" again or else it should add "lab.com" keyword to the value and store ...
1
vote
1answer
343 views

Ansible task for searching words

With my ansible task I wanted to check if openjdk is installed on environment. - name: Check if java is installed on environment shell: rpm -qa | grep 'openjdk' register: result As result I ...
0
votes
1answer
154 views

Ansible jinja2 filter reject

I need to reject "*" from stdout lines. "stdout_lines": [ "rchinnn01", "rchinnn02", "*" ] - set_fact: nfs_clients: "{{ nfs_clients_out.stdout_lines | reject(...
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 ...
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 ...
1
vote
1answer
99 views

Arch: Is there any chance to use Apache all default for 2 or more virtual hosts?

I consider establishing an Arch based LAMP. From reading this document, it seems there is must configuration to be done just for Apache itself, not to mention MySQL and PHP. In Debian LAMP there's ...
0
votes
1answer
47 views

LAMP DB-agnostic way to create a DB stack

Is there a LAMP-MySQL (or equivalent) agnostic way to create a DB stack that includes: DB-user and a relative password DB with the same name as of the user Setting a host for the DB (say, localhost) ...
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 ...
0
votes
0answers
48 views

How can I import an OVA into RHEV oVirt with Ansible

I am using both Ansible and RHEV and notice there does not seem to be a way to import an OVA into a RHEV oVirt environment using the Ansible oVirt VM module. I have a prebuilt VM I exported as an OVA ...
0
votes
2answers
2k views

Ansible: send email on unreachable host

I'd like to get an email sent whenever one of the hosts in ansible cannot be reached through SSH. I've tried to write a playbook to do this (see below). After gathering facts, any unreachable host is ...
0
votes
1answer
4k views

Updating yum repo in RHEL 7 with Ansible

I have been trying to write a playbook that adds the EPEL repo to the list of repos available. The playbook I have is: - hosts: all # define variables. vars: epelReleaseMajorVersion: 7 ...
0
votes
1answer
57 views

Building projects from source - determining / changing bin location?

I have pulled down a git repository for Ansible and followed the instructions to build it. I'm not familiar with the process of building from source and am somewhat confused. http://docs.ansible.com/...
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 ...
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 ...
0
votes
2answers
6k 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
84 views

Ansible configuration file

I have my Ansible.cfg file in /etc/ansible/ as well as /apps/ansible/ We have made all the required setup in /apps/ansible/. Now, I have created new user and have all the ssh keys setup for the client ...
0
votes
1answer
59 views

Why does upgrading through Ansible commonly considered “idempotent”?

I know that an idempotent function returns a result which is can be returned more than once without changing the application essentially (like adding zero to a number or multiplying that number by 1). ...
0
votes
1answer
242 views

How to run Ansible playbooks only if there are no problems in the playbook?

I have learned of the command ansible-playbook example.yml --check which can tell me if something in my playbook is problematic (as far as Ansible can recognize). I think I should combine this ...
0
votes
1answer
41 views

What's the difference between CMs “push” method (Ansible) to “pull” method (Chef/Puppet)?

I know that some of the advantages of Ansible over many other CMs are these: Ansible's scripts being written in YAML, a simple serialization language. The fact that one doesn't have to install it on ...
1
vote
1answer
5k views

Ansible, attempting to get specific regex pattern to work with lineinfile module

As per my question above: "Ansible, attempting to get specific regex pattern to work with lineinfile module" Essentially, I'm trying to get it to work in a single play as opposed to 2 separate plays, ...
0
votes
0answers
45 views

Is there an Ansible command to check all essential logs of a web server environment?

I use Debian stable and Apache 2.4. In the past I wrote a script with 3 different commands to read all logs of my webserver. Like: #!/bin/bash nginx -t && echo;echo;echo tail /var/log/...
0
votes
1answer
4k 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 ...
1
vote
1answer
2k views

How can I pass a positional parameter a bash script requires to it in ansible?

I have a bash script I am running in ansible with the script module. However, it needs a specific positional parameter to be specified as a server-name to function in this case as $1. I am ...
1
vote
1answer
585 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
2answers
45 views

Can kernel upgrades be done with configuration management (CM) tools for above-OS software?

I use various Linux Distros, mostly Debian-based, usually all default (I change nothing in the kernel/shell or internal-utilities (utilities that come with the distro). I usually install Apache, MySQL ...
2
votes
1answer
99 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://...
0
votes
1answer
20 views

What are the basic files (dirs and regular file) in Ansible-Galaxy roles? [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://...
0
votes
1answer
135 views

How to install Composer with Ansible?

In Bash I usually install Composer this way: curl -sS https://getcomposer.org/installer -o composer-setup.php php composer-setup.php --install-dir=/usr/local/bin --filename=composer I tried to read ...
0
votes
1answer
94 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: ...
1
vote
1answer
4k 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
56 views

Changing PHP's post_max_size and upload_max_filesize with Ansible

Is there a way to change the two famous PHP variables post_max_size and upload_max_filesize in php.ini in a version-agnostic way with Ansible? I didn't find any literature covering this and it seems ...
0
votes
1answer
151 views

Which modules are available in ansible ad-hoc commands?

I am working on Ansible. I see that we create roles and then under "tasks" folder we create main.yml. In this file, we specify which commands should be performed for this specific role. While writing ...
0
votes
1answer
452 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
404 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 ...