Closed velduz closed 2 years ago
Hey Jan,
you could refer to the machines hostname for example:
So the play is only executed on hosts which have www in their hostname.
Regards, Frank
On 13.02.21 18:13, Jan van Veldhuizen wrote:
Hi Jay,
I really like this approach, and I am playing around with it to set up the configuration playbooks for my machines. There is one thing that I am wondering, though. In your approach you have two type of machines, the servers and the workstations. But what if you want to set up a particular machine with some specific tasks? I am trying to create a repository which I can use to recreate all machines in my network, including the ones that I have for specific tasks. For example, I have a VM that runs PiHole, and I have another VM as a plex media server. Following your example, these would both be server machines, and will keep their basic server configuration up to date. But they also have tasks that are very specific for their particular function. I was thinking of copying local.yml to pihole.yml and add the pihole playbook to it. Then I have to change the cron job for this machine to pull the pihole.yml instead of the default local.yml file.
|{ ansible-pull -U -o
$(hostname).yml } || { ansible-pull -U -o } | If a hostname.yml exists, then that playbook will be run instead of the default local.yml.
Does this make sense? Or am I overlooking an easier approach?
Thanks for your examples and instructive videos, anyway!!
Jan
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LearnLinuxTV/personal_ansible_desktop_configs/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGJ5TT2FLQ6RBE4JEVRD2UTS62XMJANCNFSM4XSKJGIQ.
@ank0m , that makes sense.
Also, looking at local.yml, I can follow the same structure:
- hosts: server
tags: server
become: true
roles:
- server
- hosts: piholes
become: true
roles:
- pihole
It's also possible to add the same host to multiple groups.
Sorry I missed this comment. The code as I have it already lets you do a per-machine config. That's what the host_vars file does, and that should give you everything needed for that. If you still haven't figured this out though, let me know!
Hi Jay,
I really like this approach, and I am playing around with it to set up the configuration playbooks for my machines. There is one thing that I am wondering, though. In your approach you have two type of machines, the servers and the workstations. But what if you want to set up a particular machine with some specific tasks? I am trying to create a repository which I can use to recreate all machines in my network, including the ones that I have for specific tasks. For example, I have a VM that runs PiHole, and I have another VM as a plex media server. Following your example, these would both be server machines, and will keep their basic server configuration up to date. But they also have tasks that are very specific for their particular function. I was thinking of copying local.yml to pihole.yml and add the pihole playbook to it. Then I have to change the cron job for all machines to pull a $(hostname).yml instead of the default local.yml file.
If a hostname.yml exists, then that playbook will be run instead of the default local.yml.
Does this make sense? Or am I overlooking an easier approach?
Thanks for your examples and instructive videos, anyway!!
Jan