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
0 votes
0 answers
5 views

How to determine the color of a shell script task in Ansible?

There are various Ansible modules which can execute my own-written script (ansible.builtin.script, ansible.builtin.shell, ansible.builtin.command). However, I would like to determine the color of the ...
peterh's user avatar
  • 131
0 votes
1 answer
40 views

Ansible - 'loop' requires a list and got a list, but doesn't work

Minimal reproducible example: role/defaults/main.yaml: node_sysctl: kernel.shmall: 197951838 kernel.shmmax: 810810728448 kernel.shmmni: 4096 role/tasks/main.yaml: - name: Tune sysctl sysctl: ...
adoring_ellis's user avatar
0 votes
1 answer
27 views

How to design an ansible workflow over multiple hosts?

I am new to ansible and I am wondering how I should design my workflow with ansible in an ansible kind of way. The Task: I have a workflow/process (not ansible yet) for setting an application up. ...
Mike's user avatar
  • 1
1 vote
1 answer
35 views

How to pass the result from one task (on one host) to another task (on another host) inside an ansible playbook?

I can't get this seemingly easy play to work: --- - name: Get the filename hosts: host1 tasks: - command: # find command that returns a filename register: filename - name: Use the ...
Tim's user avatar
  • 113
0 votes
0 answers
61 views

Using `synchronize` in Ansible provisioner (Vagrant): "ssh: Could not resolve hostname default: Temporary failure in name resolution"

I'd like to perform a very basic task with Ansible: rsyncing a local file to a server (here: local vm). For this, I've installed ansible / vagrant / virtualbox, and created the following minimal ...
Andrey Tyukin's user avatar
0 votes
0 answers
28 views

Setting up winrm connections with dynamically created inventory group using ansible add_host module

I am trying to establish WinRm connections to a set of windows machines to automate a cloning task(windows vms) using ansible automation platform. I populated an inventory group called cloned_group ...
Kavisha Abeynayaka's user avatar
1 vote
1 answer
100 views

How can I put some set of machines to a group in an ansible inventory dynamically using the add_host ansible module?

I am trying to dynamically populate an inventory group called cloned_group in my current inventory . I passed the hostnames through the survey by the following names clone_machine_1, clone_machine_2, ...
Kavisha Abeynayaka's user avatar
0 votes
0 answers
38 views

How to copy a powershell script from a SCM repo to a windows machine through vmware_vm_shell ansible module

I wanted to execute a powershell script to add a local user to a windows machine without using a winrm connection. Hence i tried to copy the file from the scm repo to the windows vm and run it .I ...
Kavisha Abeynayaka's user avatar
0 votes
0 answers
20 views

Can I set a Packer provisioner attribute only if a var is provided?

I'm using the AWS builder and Ansible provisioner. If I packer a -var app_version=latest, I'd like to add the key and value as an AWS tag and/or pass to Ansible as an --extra-vars. If no value is ...
8None1's user avatar
  • 121
0 votes
0 answers
81 views

Ansible-Playbook to install Kubernetes cluster gives GPG error

For my virtualisation class, our lab assignment at the moment is to create a kubernete's cluster with 3 VM's / Nodes. I have a fourth machine where i installed ansible on that sends all correct ...
user42818's user avatar
0 votes
1 answer
88 views

Conflicts while building AWX-EE custom image

I'm currently building AWX EE custom image with the latest available but it seems latest versions got some conflicts with pip modules. My custom image was working great in July (awx-ee version 22.X 23....
motorbass's user avatar
  • 113
2 votes
1 answer
29 views

Creating a cmd task with all the private ip address details collected from gather_facts

I am running an Ansible playbook from my local laptop to AWS connecting on the public IP address. The infra is being spun up by terraform so I don't know the private IP address before hand. I have ...
ranjit abraham's user avatar
1 vote
1 answer
84 views

Ansible inventory for restart on worker node

I looking to execute a simple reboot via Ansible using its playbook - name: Worker-node Reboot hosts: node1 gather_facts: no remote_user: team become: true tasks: - name: Reboot the ...
Terra's user avatar
  • 13
0 votes
1 answer
84 views

Trying to Create a Docker Ansible lab and Cant SSH

I'm trying to setup a mini ansible lab with docker containers. I have 1 Rockylinux based container as the ansible controller, and then (for right now) 1 Rockylinux based container as the host. For ...
egkennedy93's user avatar
1 vote
1 answer
1k views

How to reload the Firewalld service using Ansible?

I have added some rules to firewalld on CentOS via Ansible. But I need to reload the firewalld daemon for the service to work properly and permanently. Is there a way to do this in Ansible? Here is my ...
Ali's user avatar
  • 113
0 votes
0 answers
35 views

How to set up an "always/finally" node in an Ansible workflow template?

I have an Ansible Automation Platform workflow template and I want to add a job to report the completion status of the template to a REST API, whether it fails or not--similar to the Finally section ...
jeremywat's user avatar
  • 133
0 votes
0 answers
38 views

get no debug on why my role is not triggered from my ansible playbook

I have a Vagrant infra to test ansible roles. Here is my playbook luis@spinoza:~/proj/g/infra/mz_devops/vagrant/deb11$ more tests/playbook_test_doc.yml --- - name: Debug role path content hosts: all ...
user3313834's user avatar
0 votes
0 answers
53 views

Is there an ansible command to configure a vmware host to synchronize time with the host?

I've been searching the docs for a bit, but is there a way in ansible - either the rest api or the built-in api - for vcenter to configure a host that has vmware tools installed to synchronize its ...
Peter Turner's user avatar
  • 1,441
0 votes
1 answer
2k views

Is there a way to declare global(?) variables inside an ansible task?

I have an Ansible playbook, this playbook has a role on it, this role is configured to run only on 2 hosts: yaml - hosts: node1,orchestrator1 gather_facts: True any_errors_fatal: True ...
k.Cyborg's user avatar
  • 175
0 votes
1 answer
225 views

Ansible Connecting to remote Docker container over SSH

I have the following situation: I have a remote server that runs docker with a Postgres container. The Postgres instance is only reachable through a docker network, not directly from the remote server....
Tiim's user avatar
  • 11
0 votes
0 answers
87 views

Identifying worker nodes from Ansible inventory group which are not yet joined to k8s cluster using ansible.builtin.regex_search and regex_replace

I am using Ansible to configure a k8s cluster with several nodes. I have a playbook which checks if a variable representing the kubeadm join command has already been defined. If it has not, it ...
Jehan Alvani's user avatar
0 votes
1 answer
53 views

How can I log every command for which an Ansible playbook uses elevated permissions?

I have an Ansible playbook that runs against a Linux target host and uses become to gain elevated permissions for those actions that require it. For auditing purposes, I need a list of all the Unix ...
jstarek's user avatar
  • 123
0 votes
1 answer
1k views

how to run powershell script as windows administrator user using ansible

i want to run a power shell script on remote windows machine. The PowerShell script will install software on C drive. The user which used to login is already in administrator group. But when the ...
heyloitsmeraj's user avatar
1 vote
1 answer
60 views

Why doesn't ansible.builtin.lineinfile behave as expected in this particular task?

I'm attempting to update /boot/firmware/cmdline.txt on a few Raspberry Pis to enable cgroup support. Seemed a good fit for ansible.builtin.lineinfile. The existing contents of /boot/firmware/cmdline....
Jehan Alvani's user avatar
0 votes
2 answers
459 views

why does my Ansible playbook throw "Found existing installation: requests 2.25.1\n\n:stderr:ERROR: Cannot uninstall requests 2.25.1"?

I'm trying to run an ansible playbook that installs docker and docker-compose and runs a compose file on a ec2 t2.micro. To use the docker modules in ansible, I need to have docker and docker-compose ...
Keshav Singh N's user avatar
0 votes
1 answer
312 views

Unable to create a project with MANUAL as source in AWX

I have followed the instructions to install AWX from this site. https://computingforgeeks.com/install-and-configure-ansible-awx-on-centos/ But I'm unable to create manual SCM project on new project on ...
Siva's user avatar
  • 223
1 vote
1 answer
50 views

ansible_become has no effect despite the ability to execute sudo on GCP hosts

Say I want to execute the following command on target hosts (deployed on GCP): ansible all -a "head -1 /etc/shadow". The command demands the root access. With the default Ansible ...
SkogensKonung's user avatar
0 votes
2 answers
297 views

Run dependencies only once in muliple plays in Ansible

I have a collection of roles that all depend on a common role: # roleA/meta/main.yaml dependencies: - role: common # roleB/meta/main.yaml dependencies: - role: common # roleC/meta/main.yaml ...
FuriousGeorge's user avatar
2 votes
2 answers
146 views

Use an asymmetric cypher to secure Ansible vault

I'm trying to develop a Playbook which must handle sensitive user data (SSH keys, Registry credentials, etc.). Only a user and the Ansible controller can see the data associated with that same user. ...
Adrien H's user avatar
  • 121
1 vote
1 answer
570 views

Ansible role depend on other roles

I have a role, foo that installs a file {{ foo_path }} that's defined in roles/defaults/main.yml. I have a second role, bar that depends on that file being there. I could put foo in the roles/meta/...
FuriousGeorge's user avatar
0 votes
0 answers
276 views

Update apt cache from ansible when user is different from root

I have the following Dockerfile I'm using to test my ansible playbook. FROM ubuntu ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get install -y git software-properties-common ansible ...
Gianluca's user avatar
  • 101
1 vote
1 answer
201 views

Use ansible to create GitHub repository with README

We use Ansible to automatically setup Kubernetes clusters. KPT https://kpt.dev/ is further used to deploy config files to pods in these clusters. In this process we need to create new GitHub ...
r3volutionxxx's user avatar
0 votes
0 answers
81 views

Is there a way to include a role once?

Suppose there is a relatively basic role that is a prerequisite for other roles, but not basic enough to be just included everywhere. The dependent roles could use ansible.builtin.include_rule, but ...
Helmut Grohne's user avatar
1 vote
1 answer
320 views

Using a different Python version in AWX

I updated a recent playbook module that says I need to use at least Python version 3.8. I run this playbook on our AWX controller. When I run the cmd module and do a "which python3" I get ...
David Desjardins's user avatar
1 vote
1 answer
2k views

Why is Ansible task getting stuck for so long?

I'm new to Ansible, I've made a playbook with only two tasks as shown below: - name: Installing Kubernetes for the master node connection: ssh hosts: x.x.x.x become_method: su tasks: - ...
Muhammed Adil's user avatar
0 votes
0 answers
75 views

How to manage ports using proxycommand and ansible

Sometimes when I'm using ansible against a fairly large number of hosts (around 100) about 3-5 of them jump to a completely different host. These devices are all connected via proxycommand using ...
Peter Turner's user avatar
  • 1,441
0 votes
1 answer
610 views

How to define rollback or rescue in ansible folder structure?

I would like to define rescue or rollback executions within my Ansible structure. I am using this recommended structure: roles rolename files tasks templates handlers ... I know ...
Vietna's user avatar
  • 25
0 votes
1 answer
813 views

Multiple shell commands not executing with shell module

For some reason this fails: - name: "Get GPG key from the Jenkins portal" get_url: url: https://pkg.jenkins.io/debian-stable/jenkins.io.key dest: /usr/share/keyrings/jenkins.io.key ...
Skegg's user avatar
  • 103
0 votes
1 answer
920 views

How to Control Ansible Loop or Task Default Output

I am trying to get my playbook to print readable debug output for stat on a number of directories when executing. The below shows the with_items and loop way and both work but the real problem is the ...
chipfall's user avatar
  • 111
2 votes
1 answer
606 views

Should I turn off copilot for text files containing secrets?

I use VSCode and have recently started using GitHub Copilot for my projects (programming and devops related). I understand that Copilot will send parts of my text to a remote server to get suggestions ...
cherouvim's user avatar
  • 141
1 vote
1 answer
344 views

Why is ansible loop adding square brackets ("[]") into my role?

I'm writing a role where I need to iterate over a list using the loop option. I'm using the ZFS module aisbergg.zfs. The role: - hosts: localhost vars: zfs_pool_name: tank ...
k.Cyborg's user avatar
  • 175
0 votes
1 answer
68 views

Where does Ansible DSL get translated to either Powershell or Python?

When running Ansible scripts, where does the translation from Ansible DSL to Python(Linux) or Powershell(Windows) happen? I assume this is on the Ansible node, that is, where the Ansible command is ...
Chris F's user avatar
  • 411
0 votes
1 answer
184 views

How to verify the time zone change is correct on AWS EC2 using Ansible?

We can use the following code to set a new timezone on AWS EC2 using Ansible. --- - hosts: linuxservers proxmoxservers remote_user: ansible become: yes tasks: - name: 'Set timezone to Buenos ...
Biju's user avatar
  • 255
1 vote
1 answer
2k views

Ansible Unsupported Parameters for using handler

I'm trying to run a ansible task but I keep getting an error. This is the play I want to run: - name: use of handlers hosts: all tasks: - name: install packages yum: name: httpd ...
Sandy's user avatar
  • 11
4 votes
1 answer
8k views

Ansible: How to get hostname without domain name?

How to get value from /etc/hostname ignoring domain name. For example, /etc/hostname says "client.test.dom" and I need to get "client". I have tried "{{ ansible_nodename | ...
Виктор Гринько's user avatar
2 votes
1 answer
524 views

How to lock a user using ansible?

Given a username, if that user exists, lock it, otherwise keep it missing. The most likely module is ansible.builtin.user. There passing password: "*" and shell: "/usr/sbin/nologin"...
Helmut Grohne's user avatar
2 votes
1 answer
1k views

How to create, but not overwrite, a file and manage its permissions with ansible?

The task seems simple. If the file does not exist, create it, otherwise retain the file and its content. In both cases, apply permissions (owner, group, mode). The most obvious candidate to this task ...
Helmut Grohne's user avatar
1 vote
1 answer
80 views

Unable to login as `ubuntu` user on ec2 instance spawned from auto scaling group

Utilizing Ansible AWS modules, I'm creating an AMI from an existing EC2 instance where I am able to ssh with both my user and default account (ubuntu). After the AMI is in a ready state, I then create ...
Chris's user avatar
  • 11
1 vote
2 answers
276 views

Is there a way to exclusively manage multiple ssh keys with differing per-key options using ansible?

Ansible provides a ansible.builtin.authorized_key module which provides a lot of functionality: You can set exclusive: true to delete all other keys. You can set key_options: .... You can list ...
Helmut Grohne's user avatar
1 vote
4 answers
299 views

What is a good strategy to prevent Ansible playbook runs against the wrong hosts? [duplicate]

It is too easy to run playbooks on the wrong hosts in Ansible I know the best practice would be to use --limit to make sure you can not select the wrong host. I do not trust --limit to ensure Ansible ...
timfox123's user avatar

1
2 3 4 5
10