proxmox ci api user

This commit is contained in:
plasmagoat 2025-06-08 20:11:50 +02:00
parent bdf3bc6b02
commit c05c863fda
8 changed files with 147 additions and 52 deletions

View file

@ -15,30 +15,31 @@
- htop
- git
- rsync
- jq
- nfs-common # If you plan to mount NFS shares
state: present
- name: Create new admin user
ansible.builtin.user:
name: "{{ admin.name }}"
groups: "{{ admin.groups }}"
shell: "{{ admin.shell }}"
name: "{{ proxmox_admin_user_name }}"
groups: "{{ proxmox_admin_user_groups }}"
shell: "{{ proxmox_admin_user_shell }}"
state: present
create_home: yes
append: yes # Ensures other groups don't get removed
when: admin.name is defined and admin.name | length > 0
when: proxmox_admin_user_name is defined and proxmox_admin_user_name | length > 0
- name: Add SSH keys for new admin user
ansible.posix.authorized_key:
user: "{{ admin.name }}"
user: "{{ proxmox_admin_user_name }}"
state: present
key: "{{ item }}"
loop: "{{ admin.ssh_keys }}"
loop: "{{ proxmox_admin_user_ssh_keys }}"
when:
- admin.name is defined
- admin.name | length > 0
- admin.ssh_keys is defined
- admin.ssh_keys | length > 0
- proxmox_admin_user_name is defined
- proxmox_admin_user_name | length > 0
- proxmox_admin_user_ssh_keys is defined
- proxmox_admin_user_ssh_keys | length > 0
# - name: Disable root SSH login (optional, but recommended)
# ansible.builtin.lineinfile:
# path: /etc/ssh/sshd_config