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
38 views

Transfer RPMs file with Ansible and localinstall them

I am having the following yaml ansible-playbook and want to transfer the rpms and then localinstall them on the remote machine. Until the transfer file step its working fine however on the ...
2
votes
1answer
12 views

Is it possible to define run_once strategy on Ansible?

I would like to run a task only on one host with Ansible. To do that, I use the parameter run_once. But what would really rock is to be able to specify a strategy to select that one host to run that ...
0
votes
1answer
31 views

Ansible replace first occurance on file

I am using Ansibles replace module, I want to replace only the first occurrence in the file. I have example string: example.string.in.my.text=test.@@sometext@@ I wish: example.string.in.my.text=...
1
vote
1answer
32 views

Ansible get a list of certification files and check their expiration date

I am trying to figure out how to get a list of .crt files from one of our web servers and check the expiration date of these certification files (actually check if these certs are valid within a time ...
10
votes
2answers
26k 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
0answers
14 views

How to save svn credentials via Ansible

I have an ansible role which will setup a Subversion server, create users with the htpasswd utility. The login of users manually work fine. However I have some scripts that will run later on via ...
0
votes
1answer
27 views

Execute command using Ansible

I want to use the dpkg -l | grep -i staff command using ansible, but it gives me an error: ansible all -m 'dpkj -l | grep -i stuff' ERROR! this task 'dpkj' has extra params, which is only allowed ...
0
votes
1answer
97 views

Ansible: difference between “shell” and “command” modules

Ansible wiki says: The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like $HOME and operations like <, >, |, ; and & will ...
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
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 ...
1
vote
1answer
20 views

ansible template module permission error

Snippet of my yaml code: - name: 11|Copy sw-installer.jinja2 response file for unattended installation template: src: "{{ CNTRL_SERVER_RSP_FILE_DIR_LOCATION_FOR_INSTALL }}/sw-installer....
1
vote
2answers
40 views

Deploy different roles on different servers using one playbook

F.e. I created two roles via "ansible-galaxy init": deploy_back and deploy_front Also I wrote a playbook.yml file. - name: Create cluster become: yes hosts: all roles: - deploy_front - ...
0
votes
1answer
32 views

Ansible User module removes sudo configuration. Why?

An Amazon Linux 2 machine is configured with a user that can sudo without password as follows: # Add user sudo groupadd -g 2002 one-username sudo useradd -u 2002 -g 2002 -c "One Username Account" -...
0
votes
1answer
18 views

Accessing variable value from inside ansible playbook

I have used the following variable in ansible playbook as shown below. --- - hosts: hosts vars: vers: 18.7 I am trying to access the value of vers using $ under tasks as shown below ...
1
vote
1answer
40 views

Linux Mint Infrastructure Management [closed]

I want to deploy Linux Mint on ~40 PCs. If I do that, I will need a centralized way to control those PCs. For Example, install/remove software on all those PCs on the same time, set environment ...
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 ...
15
votes
2answers
75k 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 - ...
1
vote
0answers
29 views

PXE boot a computer using Ironic Bifrost

I am using Openstack Ironic standalone using Bifrost. I followed this link link https://docs.openstack.org/bifrost/latest/install/index.html#introduction to install Bifrost on CentOS system in ...
-1
votes
1answer
22 views

Defining Ansible inventory on remote server

What specific changes need to be made to the code below so that the Ansible Playbook will know how to pull testFile.txt from ServerB into ServerA? These are both Amazon Linux servers. Note that ...
2
votes
1answer
532 views

yum lockfile is held by another user

Amazon Linux 2 instances are operated upon by an Ansible Playbook which performs multiple yum tasks one after the other. What specific changes need to be made to the syntax below in order for the ...
0
votes
1answer
61 views

Ansible mysql_* modules show error at first launch

This is my yml file which should update system, install mysql-server, change binding and run steps from "mysql_secure_installation". --- # tasks file for deploy_db - name: Update repos apt: ...
0
votes
2answers
433 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(...
0
votes
1answer
199 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 ...
0
votes
3answers
638 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 ...
2
votes
0answers
41 views

Ansible firewalld - guaranteed final state?

The ansible firewalld module is great for adding rules, but old rules are left in place. How can I achieve a guaranteed final state using the firewalld module? Specifically, I would like a role that ...
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 ...
0
votes
1answer
75 views

fetch dependencies while install deb with ansible

i'm trying to install mysql 8.0.15-1debian9 on a debian 9 server the problem is that mysql only provides the latest version of mysql in their apt repository which is 8.0.16-1debian9 however 8.0.16-...
2
votes
2answers
162 views

Encrypt a file on remote host

How to encrypt a file on the remote host using Ad-Hoc command 'ansible-vault'. for example, a myfile.txt on a remote machine needs to be encrypted from the host machine
0
votes
2answers
408 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
1answer
6k 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, ...
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
97 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
29 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
141 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
328 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
41 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
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....
0
votes
1answer
31 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
185 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
195 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 ...
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')...
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
270 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
128 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
224 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
2k 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
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
101 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
48 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
908 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 ...