-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
390 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,15 @@ | ||
--- | ||
auth__all: "{{ (auth__host + auth__group + auth__default) | selectattr('type', 'defined') }}" | ||
auth__all: "{{ {'host': auth__host, 'group': auth__group, 'default': auth__default} | aybarsm.helper.role_vars(only=auth__use_only) }}" | ||
|
||
__auth__config: | ||
groups: | ||
selectattr: | ||
- when: [['type', 'eq', 'group']] | ||
- when: "{{ __ansible.modules.ansible_builtin_group.uniques | product(['defined']) | list }}" | ||
logic: or | ||
authorized_keys: | ||
selectattr: | ||
- when: | ||
- ['type', 'defined'] | ||
- ['type', 'equalto', 'authorized_key'] | ||
- ['user', 'defined'] | ||
- ['key', 'defined'] | ||
users: | ||
selectattr: | ||
- when: | ||
- ['type', 'defined'] | ||
- ['type', 'equalto', 'user'] | ||
- when: "{{ __ansible.modules.ansible_builtin_user.uniques | product(['defined']) | list }}" | ||
logic: or | ||
sshd_config: | ||
selectattr: | ||
- when: | ||
- ['type', 'defined'] | ||
- ['type', 'equalto', 'sshd_config'] | ||
- ['name', 'defined'] | ||
- ['value', 'defined'] | ||
ssh_config: | ||
selectattr: | ||
- when: | ||
- ['type', 'defined'] | ||
- ['type', 'equalto', 'ssh_config'] | ||
- ['name', 'defined'] | ||
- ['value', 'defined'] | ||
ssh_config_module: | ||
selectattr: | ||
- when: | ||
- ['type', 'defined'] | ||
- ['type', 'equalto', 'ssh_config_module'] | ||
- ['host', 'defined'] | ||
sudoers_file: | ||
selectattr: | ||
- when: | ||
- ['type', 'defined'] | ||
- ['type', 'equalto', 'sudoers_file'] | ||
- ['entry', 'defined'] | ||
sudoers_module: | ||
selectattr: | ||
- when: | ||
- ['type', 'defined'] | ||
- ['type', 'equalto', 'sudoers_module'] | ||
- ['name', 'defined'] | ||
auth__users_all: "{{ auth__all | selectattr('entry__type', 'eq', 'user') }}" | ||
|
||
auth__groups_all: "{{ auth__all | | ||
aybarsm.helper.selectattr(__auth__config.groups.selectattr) | | ||
aybarsm.helper.unique_recursive(__ansible.modules.ansible_builtin_group.uniques) | | ||
default([]) }}" | ||
auth__authorized_keys_all: "{{ auth__all | selectattr('entry__type', 'eq', 'authorized_key') }}" | ||
|
||
# Use lists_mergeby to combine all sections and sort by name for better output readability | ||
auth__users_all: "{{ [auth__default, auth__group, auth__host] | | ||
map('selectattr', 'type', 'defined') | map('selectattr', 'type', 'equalto', 'user') | | ||
map('aybarsm.helper.replace_aliases', __ansible.modules.ansible_builtin_user.aliases) | | ||
map('selectattr', 'name', 'defined') | | ||
community.general.lists_mergeby('name', recursive=false, list_merge='prepend') | | ||
sort(attribute='name') | default([]) }}" | ||
auth__sshd_config_all: "{{ auth__all | selectattr('entry__type', 'eq', 'sshd_config') | | ||
sort(attribute='value', reverse=true) | sort(attribute='name', reverse=false) }}" | ||
|
||
auth__authorized_keys_all: "{{ auth__all | | ||
aybarsm.helper.selectattr(__auth__config.authorized_keys.selectattr) | | ||
aybarsm.helper.unique_combinations([['user', 'key']]) | | ||
default([]) }}" | ||
|
||
# Sort name and value to avoid unneccessary changes | ||
auth__sshd_config_all: "{{ auth__all | | ||
aybarsm.helper.selectattr(__auth__config.sshd_config.selectattr) | | ||
aybarsm.helper.unique_combinations([['name', 'value']]) | | ||
sort(attribute='value', reverse=true) | sort(attribute='name', reverse=false) | | ||
default([]) }}" | ||
|
||
# Sort name and value to avoid unneccessary changes | ||
auth__ssh_config_all: "{{ auth__all | | ||
aybarsm.helper.selectattr(__auth__config.ssh_config.selectattr) | | ||
aybarsm.helper.unique_combinations([['name', 'value']]) | | ||
sort(attribute='value', reverse=true) | sort(attribute='name', reverse=false) | | ||
default([]) }}" | ||
|
||
auth__ssh_config_module_all: "{{ auth__all | | ||
aybarsm.helper.selectattr(__auth__config.ssh_config_module.selectattr) | | ||
aybarsm.helper.unique_recursive('host') | | ||
default([]) }}" | ||
|
||
auth__sudoers_file_all: "{{ auth__all | | ||
aybarsm.helper.selectattr(__auth__config.sudoers_file.selectattr) | | ||
aybarsm.helper.unique_recursive('entry') | | ||
default([]) }}" | ||
|
||
auth__sudoers_module_all: "{{ auth__all | | ||
aybarsm.helper.selectattr(__auth__config.sudoers_module.selectattr) | | ||
aybarsm.helper.unique_recursive('name') | | ||
default([]) }}" | ||
auth__ssh_config_all: "{{ auth__all | selectattr('entry__type', 'eq', 'ssh_config') | | ||
sort(attribute='value', reverse=true) | sort(attribute='name', reverse=false) }}" | ||
|
||
__auth__key_distribute_query: "*.auth__users_apply.results[*] | [] | | ||
[?contains(not_null(item.distribute_ssh_key,``),`{{ inventory_hostname }}`)].{user: name, key: ssh_public_key}" | ||
[?contains(not_null(item.entry__distribute_ssh_key,``),`{{ inventory_hostname }}`)].{user: name, key: ssh_public_key}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
- name: Check proxmox authorized_keys exists | ||
ansible.builtin.stat: | ||
path: /etc/pve/priv/authorized_keys | ||
register: proxmox__stat_proxmox_auth_keys | ||
|
||
- name: Assert proxmox authorized_keys exists | ||
ansible.builtin.assert: | ||
that: | ||
- proxmox__stat_proxmox_auth_keys.stat.exists | ||
fail_msg: "Proxmox authorized_keys does not exist. This problem must be fixed." | ||
success_msg: "Proxmox authorized_keys exists" | ||
register: proxmox__assert_proxmox_auth_keys | ||
|
||
- name: Check Proxmox authorized_keys linked to root | ||
ansible.builtin.stat: | ||
path: /root/.ssh/authorized_keys | ||
register: proxmox__stat_root_auth_keys | ||
when: proxmox__assert_proxmox_auth_keys is success | ||
|
||
- name: Adjust root authorized_keys when not linked to Proxmox | ||
block: | ||
- name: Retrieve root authorized_keys content | ||
ansible.builtin.slurp: | ||
src: /root/.ssh/authorized_keys | ||
register: proxmox__slurp_root_auth_keys | ||
|
||
- name: Remove root authorized_keys file | ||
ansible.builtin.file: | ||
path: /root/.ssh/authorized_keys | ||
state: absent | ||
register: proxmox__remove_root_auth_keys | ||
|
||
- name: Move root authorized_keys content to Proxmox | ||
ansible.builtin.copy: | ||
content: "{{ proxmox__slurp_root_auth_keys.content | b64decode }}" | ||
dest: /etc/pve/priv/authorized_keys | ||
mode: '0600' | ||
owner: root | ||
group: 'www-data' | ||
register: proxmox__move_root_auth_keys_content | ||
|
||
- name: Link Proxmox authorized_keys to root | ||
ansible.builtin.file: | ||
src: /etc/pve/priv/authorized_keys | ||
dest: /root/.ssh/authorized_keys | ||
state: link | ||
register: proxmox__link_proxmox_auth_keys | ||
|
||
when: | ||
- proxmox__assert_proxmox_auth_keys is success | ||
- (not proxmox__stat_root_auth_keys.stat.islnk) or (proxmox__stat_root_auth_keys.stat.lnk_source != '/etc/pve/priv/authorized_keys') | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
- name: Include Proxmox datacenter pool tasks | ||
ansible.builtin.include_tasks: | ||
file: datacenter/pool.yml | ||
loop: "{{ __proxmox__cluster.pools }}" | ||
loop_control: | ||
loop_var: proxmox__dc_pool | ||
index_var: proxmox__dc_pool_index | ||
when: | ||
- __proxmox__cluster.manage_pools | default(false) | bool | ||
- __proxmox__cluster.pools | default([]) | length > 0 | ||
|
||
- name: Include Proxmox datacenter role tasks | ||
ansible.builtin.include_tasks: | ||
file: datacenter/role.yml | ||
loop: "{{ __proxmox__cluster.roles }}" | ||
loop_control: | ||
loop_var: proxmox__dc_role | ||
index_var: proxmox__dc_role_index | ||
when: | ||
- __proxmox__cluster.manage_roles | default(false) | bool | ||
- __proxmox__cluster.roles | default([]) | length > 0 | ||
|
||
- name: Include Proxmox datacenter user group tasks | ||
ansible.builtin.include_tasks: | ||
file: datacenter/group.yml | ||
loop: "{{ __proxmox__cluster.groups }}" | ||
loop_control: | ||
loop_var: proxmox__dc_group | ||
index_var: proxmox__dc_group_index | ||
when: | ||
- proxmox__role_enabled | ||
- __proxmox__cluster.manage_groups | default(false) | bool | ||
- __proxmox__cluster.groups | default([]) | length > 0 | ||
|
||
- name: Include Proxmox datacenter user tasks | ||
ansible.builtin.include_tasks: | ||
file: datacenter/user.yml | ||
loop: "{{ __proxmox__cluster.users }}" | ||
loop_control: | ||
loop_var: proxmox__dc_user | ||
index_var: proxmox__dc_user_index | ||
when: | ||
- proxmox__role_enabled | ||
- __proxmox__cluster.manage_users | default(false) | bool | ||
- __proxmox__cluster.users | default([]) | length > 0 | ||
|
||
- name: Include Proxmox datacenter ACL tasks | ||
ansible.builtin.include_tasks: | ||
file: datacenter/acl.yml | ||
loop: "{{ __proxmox__cluster.acls }}" | ||
loop_control: | ||
loop_var: proxmox__dc_acl | ||
index_var: proxmox__dc_acl_index | ||
when: | ||
- proxmox__role_enabled | ||
- __proxmox__cluster.manage_acls | default(false) | bool | ||
- __proxmox__cluster.acls | default([]) | length > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: Deploy Proxmox datacenter ACL | ||
aybarsm.linux.proxmox_acl: | ||
path: "{{ proxmox__dc_acl.path }}" | ||
roles: "{{ proxmox__dc_acl.roles }}" | ||
state: "{{ proxmox__dc_acl.state | default('present') }}" | ||
groups: "{{ proxmox__dc_acl.groups | default([]) }}" | ||
users: "{{ proxmox__dc_acl.users | default([]) }}" | ||
register: proxmox__deploy_dc_acl |
File renamed without changes.
Oops, something went wrong.