Skip to main content

Questions tagged [ansible]

Ansible is an IT automation tool. Use this tag for questions regarding the Ansible IT automation tools.

Filter by
Sorted by
Tagged with
86 votes
9 answers
225k views

Ansible: How to recursively set directory and file permissions

In ansible, I can do this: file: dest=/foo/bar/somedir owner=root group=apache mode=0775 recurse=yes And it recursively sets the owner, group, and permissions to 0775 on all directories and files in ...
Edward Ned Harvey's user avatar
33 votes
3 answers
135k views

Ansible playbook to determine OS release

I'm simply trying to check the version of ubuntu on all my servers. Based on this question I see that ansible has a ansible_distribution_version but this playbook does not show how I would simply ...
nadermx's user avatar
  • 795
27 votes
2 answers
118k views

How to count the number of elements in an array in Ansible?

An array is generated in Ansible from shell command output, it is similar to below: foo: [value0, value1, value2, value3] Now depending on output of the shell command, the number of elements of foo ...
frenchy59's user avatar
  • 373
26 votes
3 answers
111k views

How to set a default ssh user for all hosts in Ansible?

Ansible version 2.1 I have an inventory file hosts [nodes] host1 host2 ... And a simple playbook site.yml --- - hosts: all tasks: - include: tasks/main.yml If I just start the play, ...
Howard Lee's user avatar
  • 1,006
23 votes
2 answers
27k views

What is the significance of an Ansible task reporting that something has changed?

I have a task that checks if my process is listening on port 8080 and only when the exit code is not zero, would I run fail with a message. When the service is running, it reports that the status has ...
socgen hacker's user avatar
23 votes
4 answers
72k views

Can’t find the config file in “/etc/ansible/” on Mac OS X

I’m on Mac OS X and new to Ansible. I forget how I installed it. I think via pip: $ pip freeze altgraph==0.12 ansible==1.9.2 At any rate, from what I'm reading there should be a config file in /etc/...
MikeiLL's user avatar
  • 479
23 votes
1 answer
22k views

Ansible Determine Operating System

As part of my deploy script I wanna check which operating system I am deploying to. I used ansible localhost -m setup and as they say in the documentation this outputs a lot. Is there a way I can just ...
ford prefect's user avatar
14 votes
3 answers
59k views

Run a remote script/application in detached mode in Ansible

I am having trouble running a remote application startup script "detachedly" from an Ansible playbook. The script will run, but I can't get it to get/stay detached. I am probably doing something wrong,...
SadBunny's user avatar
  • 1,416
14 votes
2 answers
90k views

Ansible task to confirm if a process is running

Ansible 2.1 In the playbook, I started a process: - name: Start Automation Agent, and enable start on boot service: name=mongodb-mms-automation-agent state=started enabled=yes From play recap, it ...
Howard Lee's user avatar
  • 1,006
10 votes
5 answers
34k views

Ansible installed via pip3, but Ansible commands not found

I have installed Ansible via pip3, but I can't find the Ansible commands (ansible --version, ansible-playbook, etc.) Here's the listing that shows that Ansible is installed via pip3: :~# pip3 list | ...
Jinja_dude's user avatar
9 votes
4 answers
25k views

Ansible command-task runs into "Exec format error"

I wrote this ansible task to run a process on a remote vagrant box. (Well, actually the ansible file itself is much longer, but this is a reproducer that only runs the start script.) --- - hosts: ...
SadBunny's user avatar
  • 1,416
9 votes
5 answers
27k views

ansible: silently skip unreachable hosts

We use ansible to configure some hosts, including IP configuration. We do not want to use a DHCP server. Sometimes we add new hosts to the network. Those new hosts are in one ip address range and the ...
icehawk's user avatar
  • 235
7 votes
3 answers
21k views

Copy my ssh key to remote machine via ssh-copy-id in a script without prompt?

My usecase is that i need to copy my ssh key for authorized access onto a remote machine. I need to be able to call a script that copies over my ssh key to the remote machine without needing my input. ...
Aamir Mushtaq's user avatar
7 votes
0 answers
1k views

Writing toml sections with ansible

I have an Ansible setup for "Gitlab Runners". These use toml as configuration format [[runners]] name = "gitlab-runner-1" url = "https://example.com" token = "...
madflow's user avatar
  • 300
6 votes
1 answer
10k views

ansible: execute local_action only once while running playbook against a group of hosts (multiple managed hosts)

Is it possible in ansible to make local_action task being run ONLY once while running playbook against a group of hosts? Here is the problem: hosts: - macbooks - localhost tasks: #...<...
drew1kun's user avatar
  • 2,157
6 votes
1 answer
33k views

Ansible reports "permission denied" when issuing command on remote host

Ansible 2.1 Ansible host: Ubuntu 16.04 Remote host: CentOS 6.5 I'm quite new to Ansible. I have a simple ansible project: ├── hosts ├── roles │   └── setup │   ├── defaults │   │   └── main....
Howard Lee's user avatar
  • 1,006
6 votes
3 answers
17k views

Install Ansible in Windows, using Git-bash

I am trying to install the Ansible open source automation platform on Windows. There are many guides out there for how to install Ansible using Cygwin (eg. 1, 2). However, I already have Git-Bash ...
edesz's user avatar
  • 173
5 votes
3 answers
15k views

Can't make Ansible to wait for a server to reboot and continue playbook to work

I am creating a playbook to install a software and I need to restart the server int he middle of the playbook. I need my Ansible host to wait till the server is back and execute the rest of my tasks ...
masber's user avatar
  • 173
5 votes
1 answer
15k views

How to run very long ansible tasks?

I have following ansible role tasks: "Task 1", "Task 2", "Task 2.1", "Task 2.2", "Task 3" I need run them, but all these tasks need a lot of time to complete (from 1 hour to 12 hours) and they must ...
user avatar
4 votes
3 answers
21k views

Ansible Copy module & become - Permission denied

I am running an ansible script on localhost to copy a folder to another location. However, - name: Copy Network become: yes become_user: root copy: src: /d/ dest: "/dest/d/" mode: ...
atb00ker's user avatar
  • 157
4 votes
2 answers
3k views

Does OpenSSH support multihop login?

Ansible uses OpenSSH as the bottomed network communicative implementation, but does it support multi-hop login? I mean, if Ansible can login a server directly, but can it log in server_a then from ...
aircraft's user avatar
  • 880
4 votes
1 answer
19k views

How to remove items from an ansible list?

In my Ansible playbook, I need to change permissions on a lot of files, but a few subdirectories need read-write permissions, while most need read-only. Following another suggestion from superuser, I ...
Kevin Keane's user avatar
4 votes
2 answers
14k views

How do I install drivers silently with pnputil.exe?

When I run pnputil.exe /add-driver driver.inf /install it prompts me to first verify the publisher. I need a way to skip this step and have the publisher be verified automatically.
mython paster's user avatar
4 votes
3 answers
24k views

Ansible installed on Mac with success message but not found

I have been trying to install ansible from long time. It is giving success message when use below command. Anupams-MacBook-Pro-2:bin anupamsri$ sudo pip install ansible The directory /Users/...
user2187367's user avatar
4 votes
1 answer
9k views

Run ansible playbook on specified host and group?

Let's suppose that we have host group dev with corresponding group vars. [dev] host1 host2 How to run ansible playbook with a host3 that is not in group dev using CLI?
Grigoriy Volkov's user avatar
4 votes
1 answer
819 views

overriding options in the ansible config

In my previous question, I discovered that I can put options into a local ansible.cfg file. But can I override them? I have an ansible.cfg file that contains [defaults] vault_password_file = /home/...
hymie's user avatar
  • 1,266
3 votes
4 answers
10k views

No package matching 'docker-ce' is available with ansible

On ubuntu 18.04 I am running this ansible (version 2.5.1) role: --- - name: Add Docker apt repository key. apt_key: url: "https://download.docker.com/linux/ubuntu/gpg" state: present - ...
u123's user avatar
  • 550
3 votes
2 answers
29k views

No Ansible config file or /etc/ansible directory after trying pip and yum install

So I have been trying to install Ansible for some server management however it seems that yum and pip both don't want to co-operate: I tried a yum install which refuses to work because it cant seem ...
RickwhoPrograms's user avatar
3 votes
1 answer
10k views

Unable to form a link of a file which is in sites-available to a directory sites-enabled in remote server using ansible?

Unable to form a link of a file which is in sites-available to a directory sites-enabled in remote server using ansible? This is command I want to execute using file module of ansible: ln -s /etc/...
Karthik Vee's user avatar
3 votes
2 answers
2k views

Vagrant and Ansible facts

Is it possible to have Ansible display facts about a Vagrant box? The Ansible documentation uses ansible hostname -m setup even if I connect with the Vagrant user I would still need the SSH key to ...
user227470's user avatar
3 votes
2 answers
13k views

How to install mysql 5.7 on ubuntu 22.04?

I have upgraded server from centos to ubuntu 22.04, but I want to keep mysql 5.7. I use ansible for provisioning By default ubuntu 22.04 apt gives mysql 8, so I think I need to add repo, gpg keyring ...
Lizard Derad's user avatar
3 votes
2 answers
4k views

Managing FreeBSD host with Ansible fails: Shared object \"libdl.so.1\" not found, required by \"python\"\r\n

Management of FreeBSD on Raspberry pi 3 (FreeBSD-aarch64-12.0-GENERIC-320146M from RaspBSD project - http://www.raspbsd.org/) fails. Control host is MacOS 10.13.2. python is successfully installed ...
drew1kun's user avatar
  • 2,157
3 votes
2 answers
16k views

Permission denied in Ansible synchronize module

I'm using Ansible, among other things, for backing up purposes. I run ansible-playbook with a non-root user (let's say it is user) and ssh as user. After that, I set up privilege escalation to become ...
ntd's user avatar
  • 103
3 votes
3 answers
27k views

How to fix: "listen tcp :443: bind: permission denied" on mattermost using ansible

I am deploying mattermost in my AWS enviorment using ansible. I am trying to set a secure https connection, but I keep getting this error when I go into the logs: {:"commands/server.go:112","msg":"...
James Ukilin's user avatar
3 votes
1 answer
1k views

How to bootstrap Windows hosts with remote PowerShell for use with Ansible?

I haven't found a decent way to get a Windows instance in Azure started up using the azure_rm_virtualmachine module with remote PowerShell enabled from first boot. What is the typical approach to ...
barrymac's user avatar
  • 775
3 votes
2 answers
4k views

Ansible - ignore whitespace differences in lineinfile

I am starting to look into using ansible for maintaining a set of servers. I have ran into a difficulty with lineinfile. I am setting up rsyslog and want to make sure a few lines are in the /etc/...
MortenSickel's user avatar
3 votes
1 answer
2k views

Ansible installation on Windows 10 giving following error

Please someone suggest me how to install Ansible on Windows 10 and I've tried to do the same from GIT Bash that didn't help. Error Log: copying lib\ansible\galaxy\data\network\tests\inventory -> ...
info2m's user avatar
  • 31
3 votes
2 answers
32k views

Ansible error “ Could not find or access on Ansible Controller”

I am trying to write an ansible playbook to send certificates to my client machines from my local machine. The error message I get is: msg": "Could not find or access '/etc/icinga2/pki/...
manhasnoname's user avatar
3 votes
1 answer
796 views

Centralized management of app.config parts for self-hosted .NET services

What will be the best way to handle these scenarios, if they are not one-time, but regular: Self-hosted services on a quite a bunch of machines are needed to be repointed to different database in a ...
Andrey Ershov's user avatar
3 votes
2 answers
934 views

Ansible awx could`t gain access to script with copy: , script: and template: modules

I'm trying to write an Ansible playbook which will take a bash-script, stored on the same virtual machine, transfer this script to another virtual machine and then execute it. I've played this script ...
user1106955's user avatar
3 votes
1 answer
622 views

Uniting Putty with WSL-Ansible under the same private key and passphrase

In my PC I use Windows 10 home with WSL-Ubuntu (16.04 - xenial) and Ansible. I often rent IaaS machines and SSH into them via Putty from Win 10 and all of my IaaS machines are usually orchestrated, ...
user avatar
3 votes
0 answers
865 views

Java memory allocation error inside a Docker container when host machine is running Alpine Linux

I want to run Jenkins in a Container where my host machine is running Alpine Linux. I have an Ansible playbook that starts the Jenkins container. However, the container exits as soon as it starts. I ...
Tom's user avatar
  • 31
3 votes
0 answers
56 views

Provisioning browser extensions on Linux

I've always struggled with getting new Linux systems set up to my preferred specifications, and I've finally started to look into solutions for provisioning, saving dotfiles in git, etc. There's a lot ...
user1235777's user avatar
2 votes
3 answers
14k views

"hostname: command not found" CentOS 8

On CentOS 8 the hostname command was removed. With seemingly no way to get it back. No documented way at least Duckduckgo tells me. The problem with this approach is that the whole world expects the ...
onknows's user avatar
  • 827
2 votes
2 answers
1k views

Ansible - How to create dynamic inventory that fetches hosts from microsoft AD

I am using Ubuntu as a control-node, and would like to get the hosts from my domain controller (windows server 2022), the LDAP-Inventory Guide & microsoft.ad.ldap inventory – Inventory plugin for ...
AMM's user avatar
  • 23
2 votes
2 answers
3k views

Create SSH key without passphrase on MacOS Mojave

For years I have been using a line like this to automatically create an SSH key pair without a passphrase: /usr/bin/ssh-keygen -q -b 1024 -N "" -C "vagrant@labman01" -f keys/labkey I typically call ...
Roy's user avatar
  • 181
2 votes
1 answer
5k views

Disable root password via ansible-playbook on Ubuntu 18.04

I'm currently trying to disable root login for an ubuntu 18.04 machine via ansible playbook. If I ssh in I know I can type passwd -l root to do this. Is this the way to do it via ansible playbook? ---...
nadermx's user avatar
  • 795
2 votes
2 answers
3k views

Ansible playbook runs from user, but not from crontab

I have a weird behavior on a crontab job I'm trying to run using Ansible's playbook. First of all, I have similar crontab's lines using Ansible playbooks that works perfectly, so the issue is either ...
leosilvapaiola's user avatar
2 votes
1 answer
2k views

ansible most simple case not running - "MODULE_ARGS is not defined" error

I'm trying to begin using ansible, so I am walking thru an introduction. I've installed ansible on Debian Jessie, using apt-get. It displays version 2.2 I've configured /etc/ansible/hosts file like ...
62mkv's user avatar
  • 161
2 votes
3 answers
3k views

Ansible : Configuring a Windows Host

I'm trying to set a windows Host through a VM using mac M1 but I'm having the following issue : UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary ...
Hugues's user avatar
  • 23

1
2 3 4 5 6