Add runtime group assignment based on OS platform

This commit is contained in:
Ethan Paul 2021-09-08 21:07:14 -04:00
parent 2814d42148
commit 8fd063d21d
No known key found for this signature in database
GPG Key ID: 6A337337DF6B5B1A
4 changed files with 37 additions and 6 deletions

View File

@ -1,6 +1,14 @@
--- ---
- name: Group hosts by platform
hosts: all
tags:
- always
pre_tasks:
- include_tasks: tasks/meta/runtime-group-determination.yaml
- name: Bootstrap remote ansible environment - name: Bootstrap remote ansible environment
hosts: all,!network,!network hosts: linux
tags: tags:
- always - always
tasks: tasks:
@ -51,7 +59,7 @@
- name: Configure common server settings - name: Configure common server settings
hosts: all,!network hosts: linux
vars_files: vars_files:
- vars/packages.yaml - vars/packages.yaml
tasks: tasks:
@ -104,7 +112,7 @@
- name: Configure SSH - name: Configure SSH
hosts: all,!network hosts: linux
handlers: handlers:
- name: restart-sshd - name: restart-sshd
become: true become: true

1
playbooks/tasks Symbolic link
View File

@ -0,0 +1 @@
../tasks

View File

@ -1,6 +1,14 @@
--- ---
- name: Group hosts by platform
hosts: all
tags:
- always
pre_tasks:
- include_tasks: tasks/meta/runtime-group-determination.yaml
- name: Update system - name: Update system
hosts: all,!network hosts: linux
tags: tags:
- packages - packages
vars_files: vars_files:
@ -14,7 +22,7 @@
state: latest state: latest
- name: Update unix accounts - name: Update unix accounts
hosts: all,!network hosts: linux
tags: tags:
- accounts - accounts
- access - access
@ -32,11 +40,13 @@
- "{{ skylab_group }}" - "{{ skylab_group }}"
- "{{ skylab_group_admin }}" - "{{ skylab_group_admin }}"
- "{{ skylab_group_automation }}" - "{{ skylab_group_automation }}"
loop_control:
label: "{{ item.name }},{{ item.gid }}"
- name: Determine existing skylab users - name: Determine existing skylab users
changed_when: false changed_when: false
ansible.builtin.shell: ansible.builtin.shell:
cmd: 'grep {{ skylab_group.name }} /etc/group | cut --delimiter : --fields 4 | tr "," "\n"' cmd: 'grep "{{ skylab_group.name }}:" /etc/group | cut --delimiter : --fields 4 | tr "," "\n"'
register: _existing_skylab_accounts register: _existing_skylab_accounts
- name: Delete removed user accounts - name: Delete removed user accounts

View File

@ -0,0 +1,12 @@
---
- name: Group EdgeOS hosts
when: ansible_kernel.endswith('UBNT')
changed_when: false
group_by:
key: edgeos
- name: Group supported Linux hosts
when: ansible_distribution == "Rocky"
changed_when: false
group_by:
key: linux