r/ansible

▲ 15 r/ansible

Where to store secrets and who will be executing the playbook (which users)?

Hi everybody,

I'm have created two playbooks for my Proxmox nodes:
- Bootstrap = NAG removal, Add repos, create 2 users, setup SSH
- Proxmox_play = Setting up the whole system to my desires

The Bootstrap has to be done with elevated privileges (root: become=true). I'm passing through the root password as a vault encrypted file.

Now, for the Proxmox_play, I read that one should use a different user to perform all remaining tasks. I'm just talking about a home-lab, nothing exposed to the WWW.

  1. Do I really need to use a different user to execute all the remaining tasks, what are the implications if I don't do that?
  2. How can I tell Ansible that it should use user X with passwd Y to execute all tasks on hosts: 1, 2, 3, 4, 5, 6, etc...?

Additionally, I'm currently storing the encrypted files in a separate directory where all my ansible related stuff resides....NOT directly within the roles, though!
What is the recommendation of the community where to store these files best? (I'm not using GitHub at the moment...is something pending to learn/setup).

Thank you in advance for the recommendations.

reddit.com
u/Patrice_77 — 3 days ago
▲ 14 r/ansible

I built a self-contained Linux patch governance platform with Ansible + AWX

I've been working on a project called PatchOps : a small, reproducible environment for managing Linux patching through Ansible and AWX.

What Ansible/AWX does

  • Ansible roles for Aptly, clients, governance DB and notifications
  • Ansible playbooks for scanning, patching, promotion and rollback
  • AWX handles scheduling, job history, credentials and orchestration
  • Docker-based Execution Environment for consistent Ansible execution

There are also Grafana dashboards backed by PostgreSQL for fleet status, package upgrades, snapshots and patch history.

Everything runs on a single machine with Docker Compose, so it's reasonably easy to spin up a lab and experiment with the whole pipeline.

Blog: https://2ssk.medium.com/controlled-linux-patch-management

GitHub: https://github.com/2SSK/patchops

I'd particularly like feedback from people who use Ansible/AWX in production:

  • Does this architecture make sense to you?
  • What would you change about the AWX/Ansible side?
  • Are there better patterns for handling patch promotion and rollback?
  • What would you consider essential before calling something like this production-ready?
u/ban_rakash — 3 days ago
▲ 10 r/ansible

Cron jobs scheduling - discussion

Hi all,

I'm in a doubt here what would be best practice to use. Both solutions work for me, though. Nevertheless, I'm learning and would like to satisfy my curiosity on this one.

I'm modifying the root crontab to run an rclone script every 4 minutes on my Mac.
With Ansible, I've created a play that used the ansible.builtin.cron and the results are exactly as any example is showing:

0 11 * * 1-5   <the jobs>

Boring and for some, not very obvious.

I also did the same this, but using ansible.builtin.blockinfile to make it look like this:

# Mins  Hours   Days    Months  WkDay
#=====================================
## rclone-sync - This job will run every Monday to Friday at 11 am
  0     11      *       *       1-5   <the jobs>

I know, if both ways work, choose to your liking. What would be the choice of the community and are there any pro's or con's on both methods?

Thank you for your comments in advance.

reddit.com
u/Patrice_77 — 8 days ago
▲ 32 r/ansible+1 crossposts

Who's using Ansible for managing dotfiles/system?

Hi all!

I've used Ansible many years ago to manage VMs and other cloud infra, stopped using it but recently rediscoverd Ansible to manage my local system.

Turned my past knowledge in a set of reusable Ansible roles with a simple CLI wrapper.

Do you mange your system in the same way? :)
Curious to hear your experiences and insights!

reddit.com
u/-bwk- — 10 days ago
▲ 6 r/ansible+4 crossposts

Config tool

Hi everyone!

I wanted to share an open-source tool I’ve built to eliminate some of the daily networking routine: Network Config Tool v1.3. It’s a desktop application written in Python (Tkinter) designed for simultaneous, multithreaded configuration deployment across multiple network nodes using Netmiko under the hood.

Here is a quick breakdown of its core features:

* **Multithreading:** Runs concurrent deployments via a thread pool scaling up to 15 workers.

* **Multi-vendor Support:** Out-of-the-box compatibility with Cisco IOS, Juniper Junos, Huawei VRP, and VyOS.

* **Built-in Analytics (Matplotlib):** Tracks deployment history in a local JSON file and renders interactive trend charts directly within the GUI. Clicking a data point on the timeline instantly brings up a detailed diagnostic report (Success, Auth Error, or Timeout breakdowns).

* **Flexible Blueprint Workspace:** Allows you to append multiple configuration templates sequentially without overwriting previous text.

* **Robust Logging:** Automatically captures standard output from the remote CLI and splits it into dedicated text files named [Device_IP]_config_logging.txt.

* **Standalone Deployment:** Easily compiles into a standalone Windows .EXE binary using PyInstaller.

The project is completely free and open-source. I’d highly appreciate your feedback, constructive criticism, and, of course, some GitHub stars if you find the utility helpful!

Repository link: https://github.com/loginlocal/network-config-tool

u/archmansky — 9 days ago
▲ 10 r/ansible

Handlers or registers?

When a task depends on another how do you decide if you should use a handler or checking if the register was changed? Handlers run at the end unless you force them. Are there are other things you think about?

reddit.com
u/Beautiful-Log5632 — 10 days ago
▲ 24 r/ansible

I built a standalone AWX deployment using Docker Compose instead of Kubernetes.

I wanted AWX for a small fleet, but deploying and maintaining a Kubernetes cluster just for the automation controller felt like unnecessary infrastructure.

Rather than treating AWX as a black box, I dug into how it actually works and adapted the components needed to run it on a single Docker host.

The Article covers:

- AWX Web and Task architecture

- Receptor and job dispatching

- AWX configuration as code

Article:
https://2ssk.medium.com/running-awx-on-docker-compose-a-stand-alone-alternative-to-kubernetes-c5f53c186422?postPublishedType=initial

u/ban_rakash — 12 days ago

CrowdSec on RHEL 9: services green, zero bans — the journald gotcha that makes a "working" install parse nothing

EDIT (correction): As u/Practical_Board_1810 points out in the comments, on a stock EL9 install rsyslog is enabled and populates /var/log/secure, so the file-based setup works fine there — my original framing was too broad. The zero-parses gotcha applies to journald-only setups: minimal/cloud images, containers, or boxes where rsyslog is absent or disabled. journald acquisition works in both cases, which is why the role still defaults to it.

A few people in my fail2ban thread suggested CrowdSec for handling repeat offenders, so I moved my mail/web boxes over. Install went fine, services green — and a day later, cscli decisions list was empty while the box was visibly getting hammered.

The gotcha: RHEL 9 ships sshd logging to journald, not /var/log/secure. Most CrowdSec writeups are Debian-flavored and point file acquisition at paths that don't exist on EL9, so cscli metrics shows zero lines parsed and no scenario ever fires. The fix is a journald source:

# /etc/crowdsec/acquis.d/sshd-journald.yaml
source: journalctl
journalctl_filter:
  - "_SYSTEMD_UNIT=sshd.service"
labels:
  type: syslog

If cscli metrics shows 0 lines for sshd, you have this problem. "Service started" and "logs being parsed" are different claims — verify with metrics, not systemctl.

Second lesson, carried over from my fail2ban days: whitelist your own IP before the engine's first start, not after. CrowdSec replays logs on startup — my own flaky-VPN SSH retries from earlier in the week counted against me. A whitelist in /etc/crowdsec/parsers/s02-enrich/ does it:

name: my/admin-whitelist
whitelist:
  reason: "admin IPs"
  ip:
    - "YOUR.ADMIN.IP"

Two more EL9-specific notes: firewalld is nftables-backed, so use crowdsec-firewall-bouncer-nftables (the iptables one fights the native backend). And I keep a coarse GeoIP pre-filter (firewalld ipset + ipdeny zone files) in front so CrowdSec spends its cycles on the interesting attackers — just create the ipset with a bumped maxelem, because cn + ru together clear the 65536 default.

I packaged the whole thing — engine, nftables bouncer, journald acquisition, whitelist-first (the role hard-fails if you leave the placeholder IP), optional country blocking — into a small MIT role: https://github.com/arhab194/crowdsec-rhel

For those running CrowdSec: do you use the console/community blocklist or keep it purely local? Anyone been burned by the community list false-positiving a legit customer IP?

u/kofi_Average5837 — 10 days ago

(A)I brought Ansible playbook output formatting to 2026

I felt like the ansible ouput is a bit less modern so I made this custom Ansible callback plugin that makes playbook output actually enjoyable to read and easier to understand.

No more walls of JSON. Just clean, color-coded, output with animated per-host spinners with real-time loop progress, one host one line, grouped loop items nested under each host, recap table and failure summary

Zero dependencies, just copy paste the file and replace the default stdout callback.

Here : https://github.com/w4hf/ansible-modern-output

AI has heavily used in this project. I hope someone find this useful.

u/w4hf_ — 11 days ago

New to ansible/ very odd backup idea

Hello,

I’m very new to Reddit so this might not follow normal conventions of writing (idk I lurk every once and a while but I never post lmao). I joined a group and somehow the infrastructure is quite complex and not very documented so it’s been a lot of breaking things so I’ve been wanting to start learning ansible to automate them so if I accidentally bonk something too hard, I’ll be fine. The thing is it’s such a weird set up, but it’s secure so I can’t complain lol.

I’ve looked a little bit on this subreddit and saw lots of people recommend watching someone named geerling and their ansible stuff, and I do plan to but I had 2 other questions.

1: other than geerling, is there any other recommendations on learning ansible? I’ve been wanting to but I have already been so intimidated by it so I just kinda push it off, so I just want to have a second source to learn if I can’t understand geerling off the jump.

2: I don’t understand how I could actually do the backup itself. I do understand the basics of ansible, like how it fundamentally works (not how to make a playbook or anything like that yet) but with how everything is now I don’t see a way to make a backup ig. We have a machine at 10.8.0.17 that will run the ansible backup and put it on a hard drive that we can access if need be. We have 6 other machines that I’ll need to back up, each of them have a main user and then either a “containers”, “bots”, or “<service name>” kinda user. Most services run under those users and not the main one but you need to sudo machinectl shell containers@ or whatever the syntax is (I forgot off the top of my head). Those users however only have access to their home directory so if there is a backup script it’ll need to be run as that user because they’re running the service, I’ll then need to go to the main user, then to root and then move the backup to the main user to the scp to the ansible server. However I don’t think ansible deals with passwords and instead works with keys so it wouldn’t be able to go into the containers user or into root to move it around.

I saw another thing saying make an ansible user and then only let it have access to their backup scripts but I thought it wouldn’t work since it isn’t the one running the services so I’m kinda at a loss on how it would actually work.

Does anyone have any ideas on how to get around this or should I look at something else to do some of these backups?

Also this is all done through Alma Linux 9.8, this is basically my second to third month of actually doing live infra work so I don’t understand the super in-depth stuff but I’m feeling solid about ground level stuff so if I’m missing something very obvious, I probably just haven’t learned it yet lol.

Edit: i probably should’ve also said but didn’t think I needed to. This is a college security club and I’m the infrastructure officer. Idk if it’s needed to say it but one of the people Ik who is a common Reddit user said I should probably mention it.

reddit.com
u/BuddhaTheJudah — 11 days ago
▲ 12 r/ansible

Starting my Ansible journey as an IT System Engineer

Hey everyone,

I’m an IT System Engineer and I’m just starting to learn Ansible.

I’m hoping to get comfortable with it and eventually use it as part of my daily work. My plan is to first test and learn everything in my homelab before using Ansible in a production environment at my company.

For those of you who already work with Ansible, do you have any tips or tricks for getting started?

What should I focus on first? Are there any common beginner mistakes I should avoid? Also, are there any best practices you wish you had learned from the beginning?

I’d appreciate any advice, resources, or recommendations from people who use Ansible in real production environments.

reddit.com
u/Kle1n_ — 13 days ago

Could AI agents make application automation more runtime-aware?

I've been thinking about how automation changes once an application becomes more complex than a single server.

With tools like Ansible, you can automate a lot of the repetitive work around configuring machines, deploying services and keeping environments consistent.

But there is still a difference between knowing what you intended to configure and knowing what is actually happening inside the running application.

For example, an application might have an API, PostgreSQL, Redis, object storage and several containers. An automation playbook can configure the environment correctly, but the application can still end up with a broken service connection, incorrect environment variable or unhealthy process.

I've been exploring this problem while working with IQX.DEV. where the AI agent is designed to work with both the application and its running environment.

Instead of only looking at source code or configuration, the agent can inspect things such as container logs, running processes, ports, endpoints and service connections.

That creates an interesting workflow:

Configuration → deployment → runtime observation → diagnosis → correction

rather than treating deployment as the final step.

I'm curious where people using Ansible think AI agents could actually be useful.

Would you trust an agent to inspect an environment and recommend changes to an Ansible playbook?

Would you allow it to execute a playbook automatically after identifying a problem?

Or is it better to keep the agent completely separate from infrastructure automation and let it only provide recommendations?

I think the interesting challenge isn't giving an AI agent more control. It's deciding what information and permissions it actually needs to be useful without creating another source of infrastructure problems.

reddit.com
u/OwlZealousideal4779 — 12 days ago

tenable SC License Install automation

Has anyone discovered a way to install the security center license during the package installation? Looking to create a way to automate the installation of the server without having to manually enter the license file.

On-Premises

reddit.com
u/Shot-Document-2904 — 11 days ago

Update role vars

In role vars main.yml file I create a variable using info from ansible_facts["interfaces"].

The playbook has tasks to add and remove some net interfaces. After those tasks can I refresh the role vars so when I reference the variable it has the values of the new net interfaces?

Is there another place I can set these variables that will work? I don't want to duplicate it in vars: in every task because lots of them use this variable.

reddit.com
u/Beautiful-Log5632 — 13 days ago
▲ 10 r/ansible

When to enable become?

Do you enable become on a playbook level or on a task level? I tend to enable it on a playbook level but I'm thinking it might be better to enable only for tasks that require it, which is most to be fair.

reddit.com
u/HeadlessChild — 13 days ago