Questions tagged [ansible]

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.

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. It manages nodes over SSH and does not require any additional remote software to be installed on them. Modules work over JSON and standard output and can be written in any programming language. The system uses YAML to express reusable descriptions of systems.

The platform was created by Michael DeHaan, the author of the provisioning server application Cobbler and co-author of the Func framework for remote administration. It is included as part of the Fedora distribution of Linux, owned by Red Hat inc., and is also available for Red Hat Enterprise Linux, CentOS and Scientific Linux via Extra Packages for Enterprise Linux (EPEL) as well as other operating systems. Ansible was commercially supported and sponsored by AnsibleWorks. Since October 2015 Ansible is owned by RedHat.

It was named by DeHaan after the fictional instantaneous hyperspace communication system featured in Orson Scott Card's Ender's Game.

1762 questions
8
votes
4 answers

How to loop through interface facts

The setup module from ansible provides the fact ansible_interfaces "ansible_interfaces": [ "lo", "eth0", "eth1" ], And per interface some facts: "ansible_eth0": { "active": true, "device": "eth0", "ipv4": { …
Vincent
  • 291
  • 1
  • 4
  • 10
8
votes
2 answers

Capture template output on the fly

I need to run a command on the target server that accepts data through stdin only. The data I'm feeding it comes from a template file and contains sensitive data, so I'd rather not have it sitting in the filesystem even for a second. I'm trying to…
gtirloni
  • 5,746
  • 3
  • 25
  • 52
8
votes
2 answers

Ansible with SSH keys

Moving from Puppet to Ansible. Like the fact that it is agent less and SSH driven. I just setup two test VMs. One as the Ansible server (yes overkill), and the other as an example client (random Linux server). All our servers use public private key…
Atomiklan
  • 549
  • 1
  • 8
  • 16
8
votes
1 answer

Ansible: run different plays on the same host as different users

I want to manage two user accounts, which happen to be on the same host (mylaptop). I have a separate play for each of them. However, Ansible keeps executing both plays as the same user, despite what I wrote in my…
Jan Warchoł
  • 253
  • 2
  • 9
8
votes
4 answers

Launching an EC2 Instance with an IAM Role Using Ansible

I'm trying to launch an instance with an IAM Role using Ansible. But I don't find how to do it. Does anyone know if it is possible? If I can't use Ansible. I try it with boto
8
votes
2 answers

How do I make Ansible actually compile a config file having changed my debconf settings for an application?

I'm using Ansible to try to configure all of the workstations involved with a particular project to be able to use BitTorrent sync with a standard configuration (this is actually just an example of the kind of thing I want to do). When I execute the…
Salim Fadhley
  • 183
  • 1
  • 4
8
votes
2 answers

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 ansible. I feel like this must be a pretty common…
Ben
  • 391
  • 1
  • 3
  • 11
8
votes
1 answer

Using more advanced filters with ansible setup module

I'm new to ansible, but I cant find the answer to this question which I think looks fairly simple.. In playbooks, you can get facts in ansible using example {{ ansible_eth0["ipv4"]["address"] }} or {{ ansible_eth0.ipv4.address }}. How can I grab the…
xeor
  • 181
  • 1
  • 1
  • 4
8
votes
1 answer

Ansible ssh as user and execute has root (expect like)

I have to administer an important number of hosts where there is only one user able to access from SSH (let's call him foo) and then have to login as root to execute privilegied commands. Foo user doesn't have any kind of sudo privileges so I'm…
Arka
  • 173
  • 1
  • 2
  • 8
8
votes
5 answers

Run included ansible task as standalone task

I have many Ansible playbooks that will get included in much larger playbooks. For example: --- - name: Add user me user: name=me comment="Me" uid=9999 groups=somegroup - name: Add my ssh public key authorized_key: user=me key="{{ lookup('file',…
Pyzo
  • 135
  • 1
  • 1
  • 7
8
votes
2 answers

Ansible playbook to upload and execute a python script

My playbook is as below: - hosts : mygroup user : user sudo : yes tasks : - name : Copy script copy : 'src=/home/user/Scripts/logchecker.py dest=/opt/root2/logchecker.py owner=root group=root mode=755' - name : Execute script …
nitins
  • 2,579
  • 15
  • 44
  • 68
8
votes
1 answer

How to get item from list

Given this list: colors: red: enabled yellow: enabled green: disabled blue: enabled purple: disabled How can I get a list of the colors that are enabled (below doesn't work): - debug: msg: "{{ item[0] }}" when: item[1] == 'enabled …
BrillCom
  • 139
  • 2
  • 9
8
votes
3 answers

How can I override a playbook var if it's set in host_vars in Ansible?

server1 is in the group it_servers, but I'd like to use ansible_connection: local. How can this be done if ansible_connection is defined in the playbook and the host_vars? -- - hosts: it_servers vars: ansible_connection: aws_ssm roles: -…
bayman
  • 243
  • 1
  • 4
  • 10
8
votes
2 answers

Ansible, only disable existing users?

I have a list of users in a yaml files, with a flag: state. If the flag is undefined or if it is != "absent", I create the user : - name: "create account for {{item.name}}" user: name: "{{item.name}}" create_home: no …
8
votes
1 answer

Extracting part of the string using Ansible regex_search and save the output as a variable

I'm having a content like below inside a file. dataDir=/var/lib/zookeeper 4lw.commands.whitelist=mntr,conf,ruok,stat syncLimit=2 I wanted to read the value for dataDir using Ansible and set it to a variable. I have written following code but…
AnujAroshA
  • 213
  • 1
  • 3
  • 7