Questions tagged [ansible]
Ansible is an IT automation tool. Use this tag for questions regarding the Ansible IT automation tools.
252
questions
0
votes
0
answers
7
views
How to correctly shutdown widows systems via ansible
We have a working setup for ansible with windows via ssh. I know ssh is officially not supported, but the following behavior is more random:
For our laptops I want to shut them down via ansible after ...
0
votes
1
answer
170
views
Linux RHEL 7 - Ansible - Execute command in shell is normal but got file not found/permission denied when run via script
I have an Ansible body as follow
- name: install
command: sh /installScript.sh
args:
chdir: /home/cust/
then I execute my playbook using this
ansible-playbook -i my_inventory....
2
votes
1
answer
169
views
Update OS Via Ansible Determine What Distrubution Major Version
I've created an Ansible role that consists of no more than tasks and some variables. Probably overkill at this point but I plan to expand on the role sometime in the future. I'm attempting to first ...
0
votes
0
answers
26
views
undefined variables for grafana dashboard deployed via ansible
I deploy grafana role and dashboards on k8s server via ansible
my-dashboard.json.yml.j2
dashboard file has variable for target legendFormat
looks like
"legendFormat": "{{ pod }}"
...
0
votes
0
answers
127
views
Ansible not able to execute command with sudo privileges, but the command work when launched manually
I'm kinda stuck on this: I'm trying to automate some task on a target MacOS machine, but the commands that need sudo work only when launched manually, and not with Ansible.
An example of a pretty ...
2
votes
1
answer
344
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 ...
0
votes
0
answers
92
views
Is there a way to create disk partitions on Vagrant vm?
I have tried everything so far but without result. I have a ansible role which creates partitions on the machine. I'm trying to set up the partitions on the vm but i can't (i'm using libvirt as ...
1
vote
0
answers
30
views
Map a vagrant disk to ansible host file
I'm trying to create partitions in Vagrant vm and to map them to an ansible host file but the play that i'm running is not recognizing them.
Here's the Vagrantfile configuration:
Vagrant.configure(&...
1
vote
1
answer
59
views
How to assert a specific minimum Java version before running an ansible task?
I would like to ensure Java is installed and the oldest acceptable version is 11.
How can I achieve that in ansible?
I have tried
- name: Fetch Java version
shell: java -version 2>&1 | grep ...
0
votes
0
answers
485
views
Building wheel for ansible (setup.py) ... error, unable to install ansible
I am trying to install ansible via pip, but installation failed with these errors.
Basicly the core ansible is installed but I have a feeling that not all modules/ ansible_collections are installed
#...
0
votes
0
answers
188
views
Accessing WSL2 filesystem on localhost through WinRM
Is it possible to somehow access WSL2 filesystem (say \\wsl.localhost\Ubuntu\home\foo\bar) when WinRM remoting into localhost using certificate based authentication method?
I am trying to do so from ...
1
vote
1
answer
111
views
How can I start the PF service without interrupting existing connections?
I have an Ansible playbook that starts the PF firewall. It freezes at this point because the SSH connection between the target and the host Ansible is executing on is interrupted as a result of this. ...
0
votes
0
answers
267
views
Vagrant ansible provisioning not working
I have a vagrantfile and am trying to instantiate a final provisioner of type ansible where I intend to do the bulk of the work configuring the vm.
The Vagrantfile works fine without the ansible ...
1
vote
1
answer
567
views
Ansible Json Query
I got an dictionary output as below from one of the Ansible Task
"
msg": {
"vSwitch0": {
"failback": true,
"failover_active": [
...
0
votes
0
answers
28
views
Distribute a github private repo app via ansible
I have a simple app developed locally and want to distribute it to my ansible controlled remote servers. I have the app in a private Github repo and thought of creating a read-only token for this repo ...
1
vote
0
answers
2k
views
Ansible automatic ssh authentication using passphrase protected private key
I can't seem to get ansible to automatically pick up the SSH identity that I've added, and if I am prompted for the passphrase on my private key my passphrase seems to not be accepted, while the same ...
2
votes
0
answers
232
views
Vagrant - Ansible - Install PostgreSQL and Postgis
I'm trying to install PostgreSQL and Postgis with Ansible on a Vagrant VM.
The VM is only use locally for local development, so that's why I grant access to databases.
But I'm reaching some issues to ...
0
votes
1
answer
1k
views
Ansible hosts not working using specified inventory
I have two files
inventory.yaml:
servers:
hosts:
nas:
ansible_host: 10.10.10.27
router:
ansible_host: 10.10.10.1
and playbook.yaml
- name: pylonl playbook
hosts: all
tasks:
...
0
votes
2
answers
4k
views
I want to search for string in a file using ansible
- name: extract a word
ansible.builtin.lineinfile:
path: /file/to/path/file.log
regexp: '^nodeagent stopped: (.*)'
line: '...
0
votes
0
answers
202
views
Ansible - Get DNS servers configured on a Windows host
What is the best way to get DNS servers configured on a Windows host using Ansible?
The setup module does not seem to collect a fact with DNS server addresses.
I am currently using win_powershell ...
2
votes
3
answers
818
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 ...
0
votes
0
answers
206
views
Remove-Item with force option not working
Remove-Item with force option not working
I am trying to follow along https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-item?view=powershell-7.3 and implement ...
1
vote
0
answers
29
views
configure subnet based on LLDP neighbour
I am looking for some help to configure subnets between the routers
please refer to the diagram1
Diagram:
Router Identification comes from the host variable file
eg.
ansible_host: 10.10.10.1
ID: 1
...
0
votes
0
answers
40
views
SSH doesn't show anything
I am using Hamachi as the network to connect to other machines via Ansible and SSH, I have added each IP provided by hamachi (1 for windows, 2 for linux). SSH user@ip only works from the windows, and ...
1
vote
0
answers
87
views
Implementing the right conditions for a yum command for centos5 in Ansible
I'm currently working with a centos5 host and I have to install some packages with yum.. unfortunately, as far as I know, centos5 doesn't support Ansible's yum module so I have to use the 'command' or ...
0
votes
1
answer
704
views
ansible_default_ipv4.address Ip address range
The playbook I'm writing can run on multiple environments and each environment is on a different subnet.
I'm writing a conditional block which will only run if the host IP is of the range I will ...
0
votes
0
answers
78
views
WINRM configuration on HTTPS port
I have an issue with WINRM configuration. Once I changed HTTP port from 5985 to 5986 I cannot create new HTTPS record with the cerfificate as error said "File already exist" New-...
0
votes
0
answers
331
views
Ansible error - command timeout triggered
I am running an ansible playbook and I am getting the following error, anybody can help with this, please?
*************************************************************************
*** TASK [configure ...
0
votes
1
answer
330
views
Install ansible 2.5 in Ubuntu 22.04
I'd like to install Ansible 2.5 in Ubuntu 22.04, because our deployment playbook incompatible with Ansible newer version. I tried installing from apt, but ppa doesn't provide 2.5 for 22.04. Installing ...
1
vote
1
answer
260
views
fetching multiple files from a host based on a naming pattern with Ansible
I have a folder on a remote that looks like this.
> ls -la
-rw-rw-r--. 1 postgres postgres 469 15. Aug 12:37 220815.sql
-rwxr-xr-x. 1 postgres postgres 82 30. Dez 2015 client-postgres
-rw-------...
1
vote
1
answer
178
views
How do I convert a VM snapshot creation time to use in a math equation?
[EDIT] I am editing the original question for more clarity
I am trying to build an Ansible script that will delete snapshots over 10 days old. The value that is returned by community.vmware....
3
votes
0
answers
655
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 = "...
1
vote
1
answer
35
views
How do use dictionary variables from two sources in Ansible?
We have an Ansible script that sends an email when a server has been updated. In the script I want to to use variables from two different locations for the send to addresses. The first location is ...
3
votes
2
answers
11k
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 ...
0
votes
0
answers
150
views
Change Virtualbox default VM folder with Ansible
I'm trying to set up a computer that will act as a server using Ansible. Basically this works quite well but I got one command that I cannot get to work. I want to install Virtualbox and change the ...
0
votes
1
answer
802
views
How to use wildcard in 'win_stat' module in Ansible?
I created below Ansible script where I check if a directory is present or not with wildcard but it failed for me:
- host: windows
vars:
dir: 'c:\inetpub\wwwroot\mysite*' # without * playbook ...
0
votes
1
answer
1k
views
Linux - Setting up a multi-user and multi-machine system where anyone can log to their user from any machine
I Have the following setup:
Many computers (all of them have the latest Ubuntu), and more users than computers. I would like to make it so anyone can log to their user from any computer, and they have ...
0
votes
1
answer
552
views
Ansible variable in action (get first ip of second interface) with jinja
I need to get the first IP of the second interface on my server (within a jinja variable).
---
- name: Playbook testing
hosts: all
become: true
tasks:
- name: Debug
debug:
msg:
...
0
votes
0
answers
396
views
Need ansible task to open CIFS share on localhost
I an creating a "recovery" ansible playbook, and I need to
link to a read-only share on the backup machine so I can copy files.
The share on the backup machine is //io.hcs/backup. In windows ...
1
vote
1
answer
24
views
How can I create RedHat VM and Ubuntu VM with one Vagrantfile?
Below is my Vagrantfile. However, instead of creating 1 RedHat VM and 2 Ubuntu VMs, it "vagrant up" 3 Ubuntu VMs.
Could someone let me know why?
Thank you in advance!
Vagrant.configure("...
1
vote
1
answer
43
views
Ansible roles supposed to install different mounts dependent on subnet, install all mounts on anything
My ansible script is doing a great job at putting all the mounts on any system I specify. But my intention was to install mounts dependent on subnet.
People on .35 are privileged and need acccess to ...
1
vote
1
answer
486
views
(Re-)starting a systemd unit with user input on Ansible
Tools like gocryptfs have some advantages when they're used in combination with systemd, because dependency, status and permissions can easily be defined.
Since it needs a passphrase, it would either ...
1
vote
2
answers
2k
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 ...
2
votes
1
answer
2k
views
Cannot uninstall ansible with pip or brew on Mac OSX
I cannot remove ansible from my machine.
If I run:
which ansible
/usr/local/bin/ansible
and
ansible --version
ansible 2.7.0
...
0
votes
1
answer
1k
views
Ansible playbook hangs in interactive mode
If I run the command (redis-cli --cluster create 192.168.1.10:6379 192.168.1.11:6379 192.168.1.15:6379) from the host(192.168.1.10) it prompts me for "yes" and it's working but in ansible ...
0
votes
1
answer
1k
views
Ansible UFW allow outgoing, deny incoming
try to roll out UFW via Ansible.
- name: Install UFW Firwall
hosts: all
tasks:
- name: UFW enabled
community.general.ufw:
state: "enabled"
policy: "deny&...
0
votes
1
answer
317
views
Microsoft VisualFoxPro 9 silent install with Ansible
I need to automate Microsoft Visual FoxPro 9 installation via Ansible, but it seems like VFP9 installer does not have silent install mode.
(please note that I am installing MS Visual FoxPro 9, not a ...
0
votes
1
answer
222
views
Ansible creates DNS records in FreeIPA differently than when they're created manually
I've found that Ansible creates DNS records differently than when I create them manually; particularly when creating the Reverse DNS records (PTR). I'm running Ansible version 2.9.27 on Rocky Linux ...
0
votes
0
answers
303
views
ansible: copy file between hosts when ssh keys are not setup
This is not another question about how to copy a file between remote hosts, I already know how to do that. I'm asking for workarounds when the involved servers are not setup to trust each other (...
0
votes
0
answers
2k
views
How to disable syntax errors on ansible template files?
I am using VSCodium with the Docker plugin. When I have a docker-compose file in an ansible
template folder, the linter will show syntax errors whenever it encounters jinja2 template-variables.
The ...