From 759df2f5937062454a5b8d6b396d740eed1fa208 Mon Sep 17 00:00:00 2001 From: Salt Date: Sat, 7 Aug 2021 17:09:20 -0500 Subject: [PATCH] Allow for dynamic tagging of ansible-pull hosts --- playbooks/ansible-pull.yml | 22 ++++++++++++++++++++++ playbooks/desktop.yml | 8 -------- site.yml | 5 +++++ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100755 playbooks/ansible-pull.yml diff --git a/playbooks/ansible-pull.yml b/playbooks/ansible-pull.yml new file mode 100755 index 0000000..197949d --- /dev/null +++ b/playbooks/ansible-pull.yml @@ -0,0 +1,22 @@ +#!/usr/bin/env ansible-playbook +# vim:ft=ansible: +--- +- hosts: tags_ansible-pull + roles: + - role: ansible-pull + tags: [ ansible ] + - role: git + vars: + git_repos: + - repo: "{{ ansible_pull_repo }}" + dest: /etc/ansible + tags: [ ansible ] +- hosts: all + tasks: + - name: disable ansible-pull when not tagged + systemd: name={{ item }} state=stopped enabled=no + with_items: + - ansible-pull.timer + - ansible-pull.service + when: "'tags_ansible-pull' not in group_names and item in services" + tags: [ ansible ] diff --git a/playbooks/desktop.yml b/playbooks/desktop.yml index 4d15e7d..2aeb9c6 100755 --- a/playbooks/desktop.yml +++ b/playbooks/desktop.yml @@ -11,14 +11,6 @@ mount: path=/nfs/pi-storage-1.desu.ltd src=pi-storage-1.desu.ltd:/srv/nfs fstype=nfs4 opts="rsize=10248576,wsize=1048576,soft,timeo=600,retrans=2" state=mounted tags: [ desktop, nfs ] roles: - - role: ansible-pull - tags: [ ansible, desktop ] - - role: git - vars: - git_repos: - - repo: "{{ ansible_pull_repo }}" - dest: /etc/ansible - tags: [ ansible, git, desktop ] - role: backup vars: backup_s3backup_tar_args_extra: h diff --git a/site.yml b/site.yml index ae6417b..a1a116a 100755 --- a/site.yml +++ b/site.yml @@ -3,6 +3,10 @@ --- # Preambulatory system configuration - hosts: all + tasks: + - name: collect service facts + service_facts: + tags: [ always ] roles: - role: common tags: [ common ] @@ -41,3 +45,4 @@ - import_playbook: playbooks/pistorage.yml - import_playbook: playbooks/pik8s.yml - import_playbook: playbooks/desktop.yml +- import_playbook: playbooks/ansible-pull.yml