Stack Exchange Network

Stack Exchange network consists of 174 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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Use this tag for questions about Ansible, an open-source automation engine, related to using Ansible for topics such as cloud provisioning, configuration management, application deployment, etc.

5
votes
2answers
46 views

Modify sudoers file with ansible playbook template

I am trying to create a sudoers file with ansible template. The sudoers file should look like below: Cmnd_Alias LS = /bin/ls Cmnd_Alias LESS = /usr/bin/less Cmnd_Alias DU = /usr/bin/du %support1 ALL=...
0
votes
1answer
31 views

How to write logs for certain tasks only?

I am using Ansible and created a Playbook for deployment. I defined log_path in ansible.cfg and now tasks output are going to this log file. I want to send only few task's log into this log file. How ...
0
votes
1answer
35 views

Which is the best test automation tool on DevOps project running on Azure platform?

I am working on a DevOps project for my organisation . My current role is QA automation engineer. DevOps project is a platform foundation project running on azure platform. I primarily deal with ...
2
votes
2answers
94 views

Applying ansible playbook to a docker container on a remote host

I have automated the setup of several docker containers with ansible. This works pretty well but there are certain recurring tasks that have to be executed within the docker containers. It is ...
0
votes
1answer
53 views

Ansible - Handler not found on first attempt

Command run: sudo ansible-playbook site.yml --connection=local Distributor ID: Ubuntu Description: Ubuntu 18.04 LTS Release: 18.04 Codename: bionic ansible 2.5.5 I'm encountering ...
3
votes
1answer
64 views

Ansible service module running state utility

Ansible v2.5 introduced a new "running" state for the service module, the doc is not saying anything about it. started/stopped are idempotent actions that will not run commands unless necessary. ...
0
votes
0answers
45 views

Ansible not able to connect to Ubuntu server/container (Error: Permission denied)

When I am running my ansible play book I am getting an error as below. details are given below. I am rinning the ansible-playbook on localhost (CentOS7) and connecting to docker containers. It's ...
3
votes
1answer
58 views

How to properly automate CM?

Lets say I have a number of tools like docker bench security, some static security scanners etc etc. Now I have lets say free ansible edition (no expenses are considered). I have lots of logs, but not ...
0
votes
1answer
39 views

NGINX reverse proxy to dockerized nginx and ghost blog not working properly with ssl

So I had this configuration set up on a few different cloud VMs and did not have an issue using it as a reverse proxy to wordpress docker containers or MEAN stack applications. But now, I'm trying to ...
1
vote
1answer
32 views

ansible tower_project module, always getting “ansible-tower-cli required for this module”

I have a control host that has the following: ansible --version = 2.5.2 tower-cli --version == 3.3.0 tower-cli is able to connect to a remote Ansible Tower instance (note, Ansible tower itself is ...
0
votes
1answer
22 views

Ansible playbook to ensure Ruby gems are installed

Can I use ansible to make sure certain Ruby gems are installed on a list of Windows 7 hosts? How do I do this?
1
vote
1answer
100 views

problems running Ansible with become on domain-connected Windows Server

I am running several tasks on a Windows 2016 server with Ansible including: Joining it to a domain SOMEDOMAIN SOMEDOMAIN\SOMEUSER has been added to the local administrators group on the machine with ...
2
votes
1answer
122 views

Ansible Jinja template if statement

This is a snippet from my Ansible jinja template which populates an environment specific template. docker_compose_mq: <string-passed from Jenkins> docker_compose_profiles: "string" {% if "{{ ...
3
votes
1answer
52 views

Specify default arguments for Ansible playbook

When I create playbooks I often add a comments section at the top on how to run the Ansible playbook. With more options becoming available in Ansible, the list of command-line arguments also seems to ...
6
votes
1answer
93 views

How to notate ipv6 addresses in inventory file?

I have a machine, that is accessible via ipv6 only. It is setup for ssh with rsa key. Now I'd like to manage it with ansible. Unfortunately, this is not covered in the inventory documentation. So I ...
1
vote
1answer
39 views

Why screen folder in /var/run disappears in Docker container after running Ansible playbook?

Files I've got the following Dockerfile: FROM ansible/ansible:ubuntu1604py3 ENV DEBIAN_FRONTEND noninteractive RUN pip3 install ansible RUN printf '[local]\r\nlocalhost ansible_python_interpreter="...
0
votes
1answer
35 views

Deploying a SaaS solution which is custom for every customer

So we have 5 repositories (Individual web services ex. CMS/E-commerce and internal APIs) which are currently deployed as Docker containers. What we plan to do is to use these services and make a ...
2
votes
2answers
44 views

Deploy two independently hosted services in production at once without any downtime

I have two different services. Let's say Service A and Service B. Service B is dependent on Service A. Both code bases are hosted in separate repo in Bitbucket and code bases are maintained by ...
2
votes
1answer
30 views

Tool preferences for rapidly spinning up and spinning down k8s clusters

My team hosts several completely different projects on a production k8s cluster with a given configuration. We use AWS (and are starting to use Google Cloud). We have a QA cluster as well, that "sort ...
1
vote
0answers
527 views

How to handle item not in list in ansible variable?

This question may look strange as something like this is not implemented in real life. I have tried to make it very general. Here is my ansible-playbook: tasks/main.yml - name: "Setting place name ...
1
vote
1answer
878 views

Is there a way to run with_items loops in parallel in ansible?

I'm running ansible 2.2, but can upgrade if it helps. I saw this: https://github.com/ansible/ansible/issues/12086 and was pretty excited, but it doesn't seem to be in this (or any) version of ...
0
votes
1answer
580 views

How do I get dict key from ansible playbook variable?

Following is the desire output: domain.com is in gh4.allserevers.com The idea is to pass domain name ie domain.com in playbook and playbook will lookup its A record then check it against the ...
6
votes
2answers
256 views

How do I run Ansible Azure playbooks while avoiding storing credentials in files?

Background We use Ansible to provision and manage Azure infrastructure. At the moment we run Ansible "manually" i.e. we manually execute playbooks for various automated tasks. No CI infrastructure. ...
0
votes
2answers
629 views

Ansible Playbook Localhost Invocation Working Directory

I want to run an ansible playbook locally (host is localhost, like -i "localhost,") and inside the Playbook obtain the working directory from which the ansible-playbook command was invoked. However, ...
1
vote
0answers
68 views

Can I create an Azure VM from Ansible with NICs in different resource groups?

I am working on creating an Ansible playbook to Ensure required network resources for an Azure VM are present, and Create an Azure VM attached to those resources. Due to the way the organization ...
0
votes
0answers
50 views

Ansible ping hangs after one succesful ping

I have 3 hosts and when i try to ping using the command below: ansible all -i hosts/team_ansible.yml -m ping --user max --ask-pass Only i get success message from one system and then it hangs for ...
1
vote
1answer
139 views

WinRM / WSMan - getting SSL handshake error / TCP RST when connecting with IP address, correct connection when connecting with hostname

while using ansible to manage some AWS based windows machines when connecting using the IP as destination,on some machines im getting an SSL Error credssp: HTTPSConnectionPool(host='18.217.233....
-2
votes
1answer
45 views

Ansible translation: Installing Apache + Certbot in Ubuntu

I currently have a doubt for my last line of code to make it work in ansible, the code is the following: sudo apt-get update sudo apt-get upgrade sudo apt-get install apache2 python-letsencrypt-...
0
votes
1answer
174 views

Ansible Expect module times out; unable to end play or move to another module

I've noticed that the expect module will always time out and cause an rc=1 code. It's doing everything that I want it to, I just want to move to another module. How can I end the expect module and ...
3
votes
2answers
858 views

How do you simulate “sudo su <user>” in Ansible?

I have a server where my user is able to sudo to the root user without a password, and then the root user can sudo to a third user without a password. However, my user cannot sudo directly to the ...
-2
votes
1answer
67 views

Installing Ansible Controllers to build agents which best practice to use?

Trying to implement infrastructure as code. I need the ansible controller machine which pulls the updated playbooks from the git and run the playbooks to create the infrastructure. The issue is I have ...
0
votes
1answer
385 views

Ansible Expect Module hung on attempting a simulated return keystroke

I would like to use the expect module in an ansible playbook to telnet through a termserver to reach a NetApp filer. I tried the telnet module, but using the port argument after the ip address doesn't ...
-2
votes
1answer
38 views

Conditionally run certbot

I am running an ansible task that will among others install a let's encrypt certificate. I want the task to only run if the certificate has not been installed. What is the best way to check (via cmd)...
0
votes
3answers
54 views

Logging ansible crons in kibana

I have set up some crons in ansible, and I want to log when they start, finish, and if they fail. How I could do it? I don’t know so much about ansible. Regards.
0
votes
1answer
456 views

In ansible how to select specific tasks in a role according to the playbook or a more general parameter?

My understanding of Ansible roles is that they are the unit of reusability when implementing processes using Ansible, similarly to what a class or a package is in some computer languages. It ...
1
vote
1answer
298 views

How do I provision a Windows Docker container with Ansible?

I want to provision a Windows Docker container with Ansible, but I am confused about how exactly it will work. For instance if I use Packer with Linux, I know I can run ansible (which is ansible ...
1
vote
2answers
170 views

How to define constants in Ansible?

If one writes a constant in Python, then one uses uppercase: SOME_CONSTANT = "helloworld" Now I wonder how to define constants in Ansible. My first impression was to use the same convention as in ...
0
votes
1answer
937 views

Utilizing telnet with Ansible

Was wondering how to best utilize telnet, rather than SSH, with ansible. We are using a Lantronix term server, and must telnet into individual ports. More specifically, would it be best to use a ...
1
vote
1answer
73 views

Error when using 'ansible-local' provisioner with Docker container

I'm getting an error when running the ansible-local provisioner with a docker builder in Hashicorps Packer. My template (template.json): { "builders": [ { "type": "docker", ...
2
votes
1answer
90 views

Ansible Remote provisioning not working in Docker container build

I have a Packer template to start with a Docker container and provision it. The shell script provisioners seem to be working, but, while the playbook runs and seems to succeed, unlike the shell ...
1
vote
1answer
46 views

Parallelising Packer with Ansible

Issue I have an Ansible role which covers Windows, macOS and Ubuntu OS. I also have a Packer template file for each OS (due to small nuances and changes in the template file to handle provisioning) ...
1
vote
2answers
121 views

Change Ansible module based on variable or group

There are many Ansible Network modules (for example: ios_user, asa_user, nxos_user) which share the same (or similar enough) interfaces. Currently, my playbook has to conditionally execute tasks based ...
9
votes
3answers
1k views

Where to put ansible-vault password

We are planning to use ansible vault in our project to prevent leaking passwords or keys in git. The idea is to put all our sensitive data into a plain file then encrypt this file with ansible-vault ...
2
votes
2answers
66 views

Central repository hosting various binaries/applications for different platforms/architectures

I would like to improve the automation and performance when managing VMs using Ansible. One of my use cases is to install custom software on a variety of operating systems i.e Red-Hat, Ubuntu, Centos. ...
0
votes
1answer
153 views

Ansible does not create directories CentOS7

This my ansible script - hosts: localhost tasks: - file: name: add dir path: /etc/ansible/roles/webservers/'{{item}}' state: directory mode: 0755 owner: ...
4
votes
2answers
117 views

Ansible communication medium

I am a little confused as to what is the protocol that Ansible uses for communication between Controller node and Managed Remote nodes. I believed that it was "SSH" protocol. However, the official ...
2
votes
2answers
983 views

Can Ansible alone be a complete CI-CD tool?

I am new to Ansible and was wondering about the capabilities of Ansible. Can Ansible alone be a complete CI-CD tool? Scenario that needs to be implemented: As soon as a developer perform a git ...
1
vote
2answers
455 views

Creating a cron job with Ansible (ERROR! 'cron' is not a valid attribute for a Play)

I am relatively inexperienced when it comes to Ansible however I have previously created playbooks which will create a cron job successfully. For the life of me I cannot work out what is wrong with my ...
1
vote
2answers
301 views

How to install Certbot via Ansible playbook?

This is how I install Certbot in a Bash script: apt-get update -y && add-apt-repository ppa:certbot/certbot -y && apt-get update -y apt-get upgrade nginx python-certbot-nginx -y That'...
0
votes
1answer
60 views

The right way to Ansiblically deploy environments directly from Github:

Can one deploy an environment for some Linux OS (say, Ubuntu) from a raw Github playbook in a way similar to this (I wonder if it's the correct syntax)? bash <(curl -s https://raw....