Ansible

!ansible

@lemmy.world
Create post
pick a leader from all the hosts in the inventory

pick a leader from all the hosts in the inventory

I have an inventory of hosts, and from them, one of the tasks should choose a leader by running a command on each until one of the machines produces an expected output (json value.)

I want some code to run on that leader to initialize it, and then I want some of the other roles to delegate some tasks to that leader.

Not sure how to do this?

Should I use dynamic inventory to analyze a group of hosts, and create a new group (can you run built_in.command in dynamic inventory? Should I write a role task that runs the identifying command on each host, capturing the result globally if it returns what I want (but then running on each host even if I have found my leader?)

Homeserver Ansible Playbook

Homeserver Ansible Playbook

Open link in next tab

GitHub - Tywele/ansible_homeserver

https://github.com/Tywele/ansible_homeserver

Contribute to Tywele/ansible_homeserver development by creating an account on GitHub.

GitHub - Tywele/ansible_homeserver
[Help] Which modules for BTRFS or ZFS setup with Ansible?

[Help] Which modules for BTRFS or ZFS setup with Ansible?

Hello,

I need some help here. I've been trying to write my own Ansible playbook to setup my homeserver. The storage devices on this server are 1 NVMe SSD and 2 HDDs which I want to setup as a mirror. I want to setup all storage devices as either BTRFS or ZFS but I'm having trouble finding the correct modules to use in Ansible for this.

I have also found some roles in Ansible Galaxy but those are either not explained enough for me to use and seem overwhelming to use (especially in comparison to the terminal commands that are needed to setup the BTRFS volumes or ZFS pools). But just using the builtin command module in Ansible somehow feels wrong and not the right way to go about this.

Can someone point me in the right direction? Right now I think I will prefer using BTRFS.

Ansible on Windows - is it viable as a "poor man" solution to RMM?

Ansible on Windows - is it viable as a "poor man" solution to RMM?

Has anyone had success with using Ansible to manage Windows?

Scaling the Ansible Community to New Heights

Scaling the Ansible Community to New Heights

Open link in next tab

Scaling the Ansible Community to New Heights

https://youtu.be/4Ot0UjFdQLM

The Ansible community team at Red Hat is building and improving the web presence for the Ansible community. Our goal is to give everyone - from hobbyists, to...

[TIP] Including/Importing an Ansible role w/ handlers more than once

[TIP] Including/Importing an Ansible role w/ handlers more than once

cross-posted from: https://lemmy.ml/post/4593804

Originally discussed on Matrix.


TLDR; Ansible handlers are added to the global namespace.


Suppose you've got a role which defines a handler MyHandler:

- name: MyHandler
  ...
  listen: "some-topic"

Each time you import/include your role, a new reference to MyHandler is added to the global namespace.

As a result, when you notify your handler via the topics it listens to (ie notify: "some-topic"), all the references to MyHandler will be executed by Ansible.

If that's not what you want, you should notify the handler by name (ie notify: MyHandler) in which case Ansible will stop searching for other references as soon as it finds the first occurrence of MyHandler. That means MyHandler will be executed only once.

How to share files between roles

How to share files between roles

We use AAP to deploy roles. The roles are in Git. I now have 2 roles that need to deploy the same files and templates, and of course I don't want to keep 2 versions in Git. How could I solve that?

Jeff Geerling giving away his book on Ansible

Jeff Geerling giving away his book on Ansible

Open link in next tab

Ansible for DevOps

https://leanpub.com/ansible-for-devops/c/CTVMPCbEeXd3

Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.

ssh: Can't Open user config file, but the file exists

ssh: Can't Open user config file, but the file exists

I've just moved all my ansible control to a new host, but when I try to run a playbook that worked on the old host, I'm getting this error:

"msg": "Failed to connect to the host via ssh: OpenSSH_9.0p1 Ubuntu-1ubuntu7.1, OpenSSL 3.0.5 5 Jul 2022\r\nCan't open user config file /home/mike/automation/ssh_config: No such file or directory",

The directory exists, it has rw-r--r-- permissions, if I run ssh -F it works fine, but if I manually run the sshpass command it gets the same error, any ideas what might be causing this?