Questions tagged [ansible]

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.

Filter by
Sorted by
Tagged with
5
votes
1answer
118 views

How to properly automate CM based on log events?

Let's say I have a number of tools like Docker bench security, some static security scanners, etc. Now I have let's say free Ansible edition (no expenses are considered). I have lots of logs, but not ...
2
votes
1answer
739 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 ...
1
vote
1answer
350 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?
4
votes
2answers
4k 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 ...
6
votes
2answers
23k 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 "{{ ...
4
votes
1answer
666 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 ...
7
votes
1answer
2k 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 ...
3
votes
1answer
134 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="...
1
vote
1answer
174 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 ...
3
votes
2answers
95 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 ...
3
votes
1answer
52 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 ...
2
votes
1answer
17k 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 ...
21
votes
3answers
26k 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 and was pretty excited, but it doesn't seem to be in this (or any) version of Ansible documentation. The problem I'm trying to solve ...
2
votes
1answer
13k 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 ...
13
votes
2answers
3k 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. ...
7
votes
2answers
13k 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, ...
2
votes
1answer
371 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 ...
2
votes
1answer
6k 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 I'm getting an SSL Error credssp: HTTPSConnectionPool(host='18.217.233....
-3
votes
1answer
183 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-...
2
votes
1answer
997 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 ...
6
votes
4answers
11k 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 ...
-3
votes
1answer
303 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 ...
1
vote
1answer
3k 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 ...
-4
votes
1answer
79 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
755 views

How to perform logging of 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.
3
votes
1answer
11k 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 ...
4
votes
1answer
3k 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 ...
2
votes
2answers
2k 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 ...
5
votes
2answers
12k 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 ...
2
votes
1answer
179 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", ...
3
votes
1answer
286 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 ...
2
votes
1answer
141 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
1k 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 ...
31
votes
5answers
18k 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
286 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
2k 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: ...
5
votes
2answers
831 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 ...
3
votes
2answers
3k 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 commit, ...
1
vote
2answers
3k 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 ...
5
votes
4answers
5k 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
96 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....
5
votes
1answer
3k views

Creating ansible host_vars and group_vars files dynamically

Is it possible to populate host_vars and group_vars with results from a database like we do in dynamic inventories? Actually I'm doing it inside my playbook either with lookups, either by using shell ...
5
votes
1answer
2k views

Ensure a line is uncommented in an XML file using ansible

How can I use ansible to ensure that a line is uncommented in an XML file? In /etc/tomcat8/context.xml I want to ensure that the section: <!-- Uncomment this to disable session persistence ...
8
votes
1answer
2k views

How to organize infrastructure as code projects?

I have completed an Infrastructure-as-Code project using Terraform and Ansible. Currently, I organize my project as follows: Project1 Terraform ec2.tf rds.tf … variables....
21
votes
3answers
44k views

Execute multiple Ansible tasks with the same list of items

I am using an ansible playbook to configure Apache for a list of sites. The playbook has to copy the virtual host configuration template for each site into place, and then enable each site using ...
5
votes
2answers
297 views

Discovering extra args needed for running ansible playbooks

I've got a number of ansible playbooks that I come back to from time to time, some have required and optional arguments that I forget about from time to time. I know there's a list-tags, list-hosts ...
9
votes
2answers
18k views

How to run Ansible with sudo no password commands with become syntax

When I run ansible against a host machine that has some commands I need to run as root, I can't run these with "become" because it runs the commands as root instead of just running them with sudo. ...
2
votes
1answer
4k views

Compare Strings to get Unique values in Jinja2

I have a variable with list of node IP's and its respective Availability Zone. seed = { 10.18.13.12 = us-east-1a 10.18.37.93 = us-east-1b 10.18.68.147 = us-east-1a 10.18.21.55 = us-east-1b } ...
1
vote
2answers
194 views

Why to overrule role vars?

There is quite a simple setup I am sure many of us have come across: You have lean, slim and dedicate roles Every role has its own role vars Playbooks include the roles Let's assume you have a base ...
2
votes
2answers
10k views

How to hot deploy to Tomcat with Ansible

Currently I build my app with maven and use the tomcat manager to hot deploy the war file (both on windows servers). Now I want to use ansible to move away from the manual process. Would it make ...

1
4 5
6
7 8