mastodon.gamedev.place is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mastodon server focused on game development and related topics.

Server stats:

5.5K
active users

#ansible

13 posts13 participants2 posts today

How to convert an AWX/Ansible Automation Platform json inventory to an Ansible yaml inventory

lemmy.dbzer0.com/post/41154900

lemmy.dbzer0.comHow to convert an AWX/Ansible Automation Platform json inventory to an Ansible yaml inventory - Divisions by zeroI recently had the need to export an AAP inventory and use it manually with ansible. However there’s no easy way to do this and I couldn’t find anything online to do this, so I crafted a little conversion script. First of all, you need to export your AWX/AAP inventory from the API [https://access.redhat.com/solutions/3330041] (just go to https://your.awx.domain/api/v2/inventories/<inventory id>/script/?format=json&hostvars=1) and save the file locally. Afterwards, copy the below script and run it against the json inventory python import json import yaml import argparse def convert_inventory(json_file, yaml_file): try: with open(json_file, 'r') as infile: inventory = json.load(infile) with open(yaml_file, 'w') as outfile: def convert_lists_to_dicts(obj): if isinstance(obj, list): return {str(item): None for item in obj} elif isinstance(obj, dict): return {key: convert_lists_to_dicts(value) for key, value in obj.items()} else: return obj inventory = convert_lists_to_dicts(inventory) for hostname,hostvars in inventory['_meta']['hostvars'].items(): inventory['all']['hosts'][hostname] = hostvars del inventory['_meta'] yaml.dump(inventory, outfile, default_flow_style=False) print(f"Converted {json_file} to {yaml_file} successfully.") except Exception as e: print(f"Error: {e}") if __name__ == "__main__": parser = argparse.ArgumentParser(description="Convert Ansible inventory from JSON to YAML format.") parser.add_argument("json_file", help="Path to the input inventory.json file") parser.add_argument("yaml_file", help="Path to the output inventory.yml file") args = parser.parse_args() convert_inventory(args.json_file, args.yaml_file)

TIL of a deliberate source of Heisenbugs in the default sshd config:

MaxStartups 5:50:10

This means: Allow up to 5 simultaneous "starting" SSH connections. Between 5 and 10 starting connections, drop them randomly 50% of the time. Above 10: Do not allow any new SSH connections to start.

Took me a long time to diagnose why a particular combination of concurrent SSH processes would fail occasionally when connecting to this embedded machine.

simplified.guide/ssh/limit-sim

www.simplified.guideHow to set maximum SSH connections and sessions on a Linux Server

Fun question for the #NixOS #Ansible bubble:

I noticed that Ansible on NixOS does not find python modules that have been installed from NixPkgs. This means, modules like the kubernetes module are not found and Ansible cannot do its work, when a task is executed on localhost (e.g. via delegate_to)

Is there a way to install those additional modules together with the Ansible package?

Or is this just some messup with autodetecting the python interpreter on localhost?

In today's exercise in bravery/silliness, I'm going to complete reconfigure the gateway via #ansible.

Lately, I've just been running single updates:

ansible-playbook gateway.yml --tags=pf

Today, the tags are coming off. All the updates.

ansible-playbook gateway.yml

The @tailscale folks have some excellent YT videos on setting up self-hosted servers on Digital Ocean using Terraform, Ansible, and of course, Tailscale. I just got my first Droplet running.

Part 1 - Getting started with cloud-init: youtu.be/e-X5FJwrkaA?si=t3iLP-
Part 2 - Terraform: youtu.be/PEoMmZOj6Cg?si=2IwHCw
Part 3 - Ansible: youtu.be/k5Xgt31yK2U?si=28MPbw

Dear #AWX users out there (AWX as in Ansible, not AWS as in Amazon...),

does anyone have good pointers on connecting AWX and #Hashicorp #Vault / #OpenBoa **without** having to define each secret/credential again in AWX?

I have set up a basic connection according to the documentation: ansible.readthedocs.io/project
And I have created a credential using that lookup and could successfully output its value in a playbook run in AWX.

But having to define a AWX credential for each secret that I need to pull from Vault/OpenBoa sounds like a lot of unnecessary duplication.
(Yes, I know you can manage AWX via Ansible. We do that already. But still, you need to define the credentials in your code somewhere for the automation to create it in AWX)

ansible.readthedocs.io12. Secret Management System — Ansible AWX community documentation

Dear #LazyWeb / #lazyfedi,

I'm new to #k8s and am wondering how to handle templating large amounts of config files. I couldn't find anything super useful in my search so I have an #Ansible sidecar I run to generate the kustomizations and config files. My most recent Ansible change was 30 lines, it resulted in changing 5,000 lines of YAML which will further be fed to Kustomize.

There has to be a better way?

I've heard about Helm, Yoke, KRO, and using an operator pattern. My understanding of those options is:

* Helm - My Org recommends avoiding (I don't know why)
* KRO - Not stable, but FFS neither is Kustomize
* Yoke - Almost kinda operator pattern
* Operator Pattern - This feels like reinventing a fucking config manager (ala #Ansible, #Puppet, #Chef, #Saltstack) for every fucking project. What new hell this is.

I'm hoping I'm missing something because the only workable flow for this workload is:
1) Create ansible roles/playbook to generate the kustomization.yaml and resources
2) Generate those kustomizations, check them into git
3) Use Kustomize via GitOps to expand the YAML even more
4) Push a metric fuckton of YAML to production

I'm losing my mind over here.

Continued thread

Honestly, in what UNIVERSE can you remember something you don't do on a regular basis good enough to do it without having to read documentation and copy-paste stuff?

Sounds like a perfect opportunity to put that in a small #ansible role and call it with a tag or "when" clause as part of a playbook or whatever automation you have in place. 🥹

I don't know who needs to hear this, but...

I have lost count of the number of people who go something along the lines of: "I have been meaning to try ara for a long time but our teams have been so busy that we haven't had the chance"...

Stop. Take 10 minutes and stop. Try it.

Most users are pleasantly surprised and cannot believe they did not take the time before.

Now these teams save time troubleshooting their #ansible playbooks and have more time for other things.