Ansible is an open-source software platform for configuring and managing computers. It combines multi-node software deployment, ad-hoc task execution, and configuration management.

learn more… | top users | synonyms

-1
votes
1answer
43 views

Convert value of an Ansible variable from lower case to upper case

I am working on a playbook to join linux systems to Active Directory. I can't seem to find a way to convert the value of ansible_hostname to uppercase. One of the commands I need to run requires the ...
0
votes
0answers
47 views

Ansible AWS dynamic inventory: `./ec2.py --list` unauthorized

I'm trying to use Ansible's ./ec2.py --list --refresh-cache to list my AWS EC2 instances. Via documentation, I've run through this checklist: AWS (docs via Amazon's Controlling Access to Amazon EC2 ...
0
votes
2answers
21 views

Automatic retrieval of current mapping debian stable -> released name

I'm automating my customary debian setup using ansible. The playbook is supposed to treat testing/unstable and stable differently: the former are to be maintained "clean", while the latte is to ...
0
votes
1answer
26 views

Sharing simple tasks across roles in ansible?

I have a couple of different machine types that all need to have the official postgres APT repo defined for them in order to be able to apt-get install the right version of tools. These different ...
0
votes
1answer
28 views

Correct way to model so that execution order is correct - Ansible

I wish to do 4 tasks on all machines in a group. Once complete in all machines fully, task 5 must be run on one machine (Assume this is a DB instance). Once task 5 completes, tasks 6 to 10 are run on ...
0
votes
1answer
27 views

Ansible failing on condition check for role. What is a proper one?

I'm trying to do an advanced version of your script where ansible running a role basing on a result of "when" condition. In my scenario ansible connects as root, creates ansible_bot user, grants him ...
3
votes
1answer
38 views

Validate nginx.conf during ansible deploy

I have a single Ansible-provisioned server running a number of sites. My Ansible tasks look roughly like: - name: site nginx config template: src="nginx-site.conf.j2" ...
0
votes
1answer
70 views

ansible-vault encrypt credentials

I have an inventory file with one host: 10.1.32.123 ansible_ssh_user=vagrant ansible_ssh_pass=vagrant My yaml file: - hosts: all sudo: yes gather_facts: yes serial: 20 roles: It's ...
2
votes
0answers
51 views

Need to check whether you need to reboot for a kernel update?

I'm using Ansible to check hosts if they need to be rebooted if the /vmlinuz kernel doesn't resolve to uname -r. The if condition is although always identifing a reboot even though the test machine ...
1
vote
1answer
74 views

Ansible: restart service only if it was running

In an Ansible playbook, I'd like to restart a service after updating config file, but only if it was already running. I do not want to control the state of the service with ansible, only restart it ...
0
votes
0answers
27 views

Ansible fails to create Amazon EBS-ctorage

I have a problem - trying to automate the purchase of new EC2 instances. Here's my playbook: --- - name: Provision new EC2 instance hosts: local connection: ...
0
votes
1answer
43 views

Hudson GUI cannot run a job with same command that runs fine from the shell

I get this error while trying to run a job in hudson here is the log Started by user anonymous [workspace] $ /bin/bash -x /tmp/hudson3189813701500418318.sh + date Thu Feb 19 17:02:03 EST 2015 + fab ...
0
votes
0answers
35 views

Managing OpenVZ containers with Ansible

Is there any elegant way to manipulate OpenVZ containers with Ansible? Sure I can install an SSH daemon on each and put my public keys, but as soon as there is a vzcl enter command maybe there is a ...
0
votes
0answers
30 views

how to have one role deploy different files per hosts in ansible [duplicate]

I have a role in ansible but and want to use the copy module in ansible to copy the specific files for specific hosts. Not exactly but pretty same scenario .../roles/serverfiles/tasks/main.yml # ...
0
votes
1answer
63 views

How do i print the current hostname of a host in ansible

I wrote a role to edit the motd when user log into the machine, but i want to personalize the motd to print the hostname of the machine What vriable do i use? or how do i do this? template? how? I ...
0
votes
1answer
63 views

How to see stdin of ansible commands

This is basically the same question as how to see ansible stdout only I wanted to see the commands generated and passed in by ansible. Is it possible?
0
votes
1answer
48 views

Using an Ansible Do-Until loop to manage outdated directories

I have a directory that will have a series of subdirectories added to it, and I want to maintain only the most recent 5. Here are the two tasks that I think should accomplish this: - name: Get ...
0
votes
1answer
182 views

recommended way to configure a centos-7 network interface with static settings via ansible

I'm new to ansible and a little googling hasn't lead me quickly towards the right solution to my question. What's the 'with the grain' way to assign static network settings to a centos-7 host with ...
0
votes
1answer
165 views

How to do a git pull/push using ansible

I am trying to do a git pull/push using ansible. I am running ansible on one server and want to automate or orchestrate a git pull/push on a remote host. Now since i didn't find a mmodule to do this ...
1
vote
0answers
74 views

How to encrypt binary files in Ansible?

We are using Ansible Vault to store passwords, private keys for certificates etc. in our Ansible Playbook git repository. All of our existing private data is in text form, so we can store it in ...
3
votes
2answers
116 views

Ansible: a host appears in more than one group, and both groups have the same tasks in them; any way to run tasks once?

I have a playbook that looks something like this: --- - hosts: group1 roles: - role1 - role2 - hosts: group2 roles: - role2 - role3 Now say I have a hosts file that has an ...
2
votes
0answers
113 views

Ansible: setting hostname over inventory

I am new to Ansible, but a long time programmer, also worked with puppet a bit. Here is the situation, I need to initialize some network appliances, they don't talk bash so I'm using the raw module ...
0
votes
0answers
58 views

Ansible :: advanced nested looping

I have to process output from CloudFormation Outputs that is: Ansible code that produces this output: - debug: var: stack.stack_outputs Output: ok: [localhost] => { "stack.stack_outputs": ...
2
votes
1answer
161 views

dict as value for YAML key in an Ansible task

I am unable to figure out how to pass a dictionary/hash-map of key-value pairs as the value for an option in an ansible tasks. Default Options: # roles/ec2/defaults/main.yml ec2: key_name: "{{ ...
1
vote
1answer
178 views

Using ansible to add users' public keys to one user's authorized_keys file

Trying to add two people's Github public keys to a user's authorized users file. I am able to successfully retrieve the SSH keys: --- - hosts: 127.0.0.1 connection: local vars: my_users: ...
1
vote
1answer
50 views

How do I avoid showing skipped Ansible tasks?

The output of my playbooks are always completely swamped with useless output regarding which tasks have been skipped, which makes it annoying and time consuming to go through and find specific ...
0
votes
1answer
95 views

sudo and --ask-sudo-pass on CentOS 6.6

I'm running command: [kamil@server.com ]# ansible example.com -a "sudo id" --ask-sudo-pass sudo password: example.com | FAILED >> { "failed": true, "msg": "[sudo] password for kamil: ...
1
vote
1answer
67 views

ansible cannot download git repo on centos 7

I have this in my drupal roles to download drupal git --- - name: Install git yum: name=git state=latest - name: Clone Drupal git: repo=http://git.drupal.org/project/drupal.git ...
1
vote
0answers
103 views

error creating database using ansible on centos 7

I am trying to install mysql AND setup database using ANSIBLE on CentOS7(i have no idea why every documention in the world now ONLY talks about Ubuntu and NO CentOS anymore...really SAD!) here is my ...
1
vote
1answer
158 views

Running Ansible task as a specific user

I am trying to run a specific Ansible task as a different user than the one who is running the playbook. My .yml file looks like this: --- - hosts: staging_servers tasks: - name: check ...
0
votes
0answers
21 views

Python in the debian-installer context

My broader question is about using Ansible to perform the late_command in a preseeded Debian/Ubuntu install. The specific question is, is there some straightforward or documented way to get a working ...
1
vote
1answer
115 views

Ansible SSH as one user and Sudo as another

I am having trouble with configuring Ansible and sudo to allow me to SSH into a server and run a command as another user. I have gone through the questions / answers below and the Ansible ...
1
vote
1answer
102 views

Pubsub-style notify/handler in Ansible (restart all services using source code when it changes)

I have a role that updates source code of my project from git, let name it source_tree. Git repository contains source used by multiple services so I want to restart all services using that source on ...
1
vote
1answer
138 views

Prevent rsync from deleting excluded directories

I'm using rsync through Ansible's synchronize-module with the following task definition: synchronize: src='{{ local_app_path }}/.' dest='{{ remote_app_path }}/' perms=no owner=yes ...
0
votes
1answer
146 views

Ansible/Capistrano with fixed sudo command (“sudo su -”)

I have to administer some half-managed servers (monstly CentOS 6), where we are only allowed to login as a regular user, then do "sudo su -" and type the regular user password, and then run the ...
3
votes
2answers
368 views

Ansible Fails to Authenticate Sudo Even When Sudo Pass is Given

Problem Using the latest, stable Ansible build, I have an odd problem where my playbook hangs on one server during "Gathering_Facts" but works fine on other similar servers when using Sudo. On the ...
2
votes
1answer
73 views

Detecting a network from ansible playbook using nslookup

I am working on a Vagrant + Ansible configuration for my team that sets up a developer VM, some of the artifacts needed are only available from my corporate network either by being physically on it or ...
1
vote
2answers
215 views

Ansible - Exception: host not found: {{ item }}

I have some task which I wish to delegate_to some hosts (finally I want to list them in some var rather than use group from inventory). For this question lets simplify this to (I did exactly the same ...
0
votes
0answers
49 views

How to set scp_if_ssh = True for a group?

It's simple to set this variable in an ansible.cfg but it makes sense only for hosts that do not have sftp (and most likely python as well). So I have a group for routers – is it possible to set this ...
4
votes
2answers
985 views

Ansible, Chef, Puppet or ____ : Which has the strongest Windows support and smallest init footprint

We do mostly (but not exclusively) win servers. Preferably, we can start the OS and do little or nothing to it to make it ready to receive commands (we know we may need to create a base image with ...
4
votes
1answer
214 views

How can I have a nested loop with a fileglob pattern?

I'm trying to create a set of authorized SSH keys for a set of users in Ansible. I have a users variable set up like so: users: - { username: root, name: 'root' } - { username: user, name: 'User' ...
2
votes
1answer
880 views

Ansible - Try to ping connection between localhost and remote server

I am beginner in Ansible and I am trying to learn it. I use the ansile docs Getting Started and I am faced with problem which stopped me. My problem rely on that when I've tried to use a command ...
1
vote
1answer
360 views

Ansible: copy file depending on hostname or role

What's the best way to copy over a file depending on a hostname? I need to copy over files with different content but with the same filename to several machines. I have several files: file.role1 ...
3
votes
1answer
616 views

Running apt-get autoremove with ansible

I maintain a flock of EC2 servers with ansible. The servers are regularly updates and upgraded using the apt module. When I manually tried to upgrade a server, I received the following message: $ ...
0
votes
1answer
406 views

Issues with Ansible's default/error handling in a playbook

I'm having some issues with Ansible and the way it defaults to values. What I'm trying to accomplish is to bind a Docker container to on eth1, if it exists, otherwise use lo. My initial approach was ...
1
vote
1answer
960 views

Ansible: How to access hostvars in task?

I'm trying to use hostvars in my task. But it seems that ansible is interpolating the variable and then trying to look it up in the main variable dict object. Here's my code: - name: Configure the ...
1
vote
1answer
94 views

Display output with Ansible

I have a Ansible play for PGBouncer that displays some output from a stats module built into PGBouncer. My issue is that when Ansible prints the output to the terminal it mangles the newlines. ...
1
vote
1answer
739 views

Avoid repeating 'with_items' in Ansible role

I've got an Ansible role with several tasks that I run for several virtual hosts. My playbook works, and it looks like this: --- - name: Create vhost configuration # action with_items: vhosts - ...
-1
votes
1answer
615 views

How to make sudo -u not require password [closed]

I'm using ansible with vagrant and ansible is trying to sudo as postgres user to run some postgres commands. Ansible running as vagrant user seems to run something like sudo -u postgres psql This ...
3
votes
1answer
1k views

how to access host variable of a different host with Ansible?

Let's say a have a host that collects some data and it's in a group [collectors]. I also have hosts in group [reporters]. So I want to set a variable on reporters from groups['collectors'][0] ip ...