Skip to content

Commit

Permalink
feat: manage root ssh key
Browse files Browse the repository at this point in the history
  • Loading branch information
sergelogvinov committed Mar 1, 2024
1 parent 2584109 commit ebfbbe7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---

# Proxmox manages the ssh keys by itself. But if proxmox is not working properly, you cannot ssh to the server.
# In this case, you can add your ssh key to the server.
# It stores the ssh key in the /root/.ssh/authorized_keys2 file.
proxmox_sshkey: ~
# proxmox_sshkey: https://github.com/sergelogvinov.keys

proxmox_ipset: []
# - name: admins
# entries:
Expand Down
22 changes: 22 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@
with_first_found:
- "../vars/{{ ansible_distribution_release }}.yml"
- "../vars/empty.yml"
tags: ['proxmox']

- name: Add ssh keys
become: yes
authorized_key:
path: /root/.ssh/authorized_keys2
user: root
state: present
key: "{{ proxmox_sshkey }}"
exclusive: true
when: proxmox_sshkey
tags: ['proxmox']

- name: update repository
become: yes
tags: ['proxmox']
block:
- name: get proxmox apt key
get_url:
Expand Down Expand Up @@ -44,6 +57,7 @@
apt:
name: "ifupdown2"
state: present
tags: ['proxmox']

- name: install proxmox-ve
become: yes
Expand All @@ -52,31 +66,36 @@
state: present
when: proxmox_packages|length > 0
register: proxmox
tags: ['proxmox']

- name: remove repo
become: yes
file:
path: /etc/apt/sources.list.d/pve-enterprise.list
state: absent
when: proxmox.changed
tags: ['proxmox']

- name: remove os-prober
become: yes
apt:
name: os-prober
state: absent
when: proxmox.changed
tags: ['proxmox']

- include_tasks:
file: "{{ item }}"
with_first_found:
- "{{ ansible_bios_vendor|regex_replace('[ ,\\.]','') }}.yml"
- "none.yml"
tags: ['proxmox']

- name: prepare cluster firewall
shell: "touch /etc/pve/firewall/cluster.fw"
args:
creates: /etc/pve/firewall/cluster.fw
tags: ['proxmox']

- name: firewall
become: yes
Expand All @@ -86,11 +105,13 @@
owner: root
group: www-data
mode: 0640
tags: ['proxmox']

- name: prepare files
shell: "touch /etc/pve/nodes/{{ ansible_hostname }}/host.fw"
args:
creates: "/etc/pve/nodes/{{ ansible_hostname }}/host.fw"
tags: ['proxmox']

- name: node firewall
become: yes
Expand All @@ -101,3 +122,4 @@
group: www-data
mode: 0640
ignore_errors: yes
tags: ['proxmox']

0 comments on commit ebfbbe7

Please sign in to comment.