https://ip_or_domain/pve-docs/pve-admin-guide.html
ansible-galaxy install tenhishadow.pve_on_debian
# ls -l /etc/ansible/roles/tenhishadow.pve_on_debian/ 68 drwxr-xr-x. 2 root root 4096 16 22:46 defaults drwxr-xr-x. 2 root root 4096 16 22:46 handlers -rw-rw-r--. 1 root root 35147 16 22:45 LICENSE drwxr-xr-x. 2 root root 4096 16 22:46 meta -rw-rw-r--. 1 root root 1916 16 22:45 README.md drwxr-xr-x. 2 root root 4096 16 22:46 tasks drwxr-xr-x. 2 root root 4096 16 22:46 templates drwxr-xr-x. 2 root root 4096 16 22:46 tests drwxr-xr-x. 2 root root 4096 16 22:46 vars
[proxmox_target] 192.168.102.51
# ansible-playbook -i hosts testplaybook.yml
PLAY [proxmox_target] * TASK [Gathering Facts] * ok: [192.168.102.51] TASK [tenhishadow.pve_on_debian : set hostname for the system] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : modify /etc/hosts] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : check standart repos] * changed: [192.168.102.51] => (item=deb http://security.debian.org/ stretch/updates main contrib non-free) changed: [192.168.102.51] => (item=deb-src http://security.debian.org/ stretch/updates main contrib non-free) changed: [192.168.102.51] => (item=deb http://mirror.yandex.ru/debian/ stretch main contrib non-free) changed: [192.168.102.51] => (item=deb-src http://mirror.yandex.ru/debian/ stretch main contrib non-free) changed: [192.168.102.51] => (item=deb http://mirror.yandex.ru/debian/ stretch-updates main contrib non-free) changed: [192.168.102.51] => (item=deb-src http://mirror.yandex.ru/debian/ stretch-updates main contrib non-free) TASK [tenhishadow.pve_on_debian : add pve repository key] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : add pve-no-subscription repo] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : update system] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : install proxmox packages] * changed: [192.168.102.51] => (item=[u'proxmox-ve', u'postfix', u'bridge-utils']) TASK [tenhishadow.pve_on_debian : remove os prober to prevent injuring VMs] * changed: [192.168.102.51] => (item=[u'os-prober']) TASK [tenhishadow.pve_on_debian : search for standard kernels] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : remove standart kernels] * changed: [192.168.102.51] => (item=[u'linux-image-4.9.0-4-amd64', u'linux-image-amd64']) TASK [tenhishadow.pve_on_debian : configure network from template] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : rebooting the server] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : waiting for server to come back] * k: [192.168.102.51 -> localhost] TASK [tenhishadow.pve_on_debian : remove enterprise repo] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : install several packages] * changed: [192.168.102.51] => (item=chrony) changed: [192.168.102.51] => (item=htop) ok: [192.168.102.51] => (item=telnet) changed: [192.168.102.51] => (item=nmap) changed: [192.168.102.51] => (item=screen) changed: [192.168.102.51] => (item=tcpdump) changed: [192.168.102.51] => (item=iptraf) changed: [192.168.102.51] => (item=sudo) ok: [192.168.102.51] => (item=bridge-utils) TASK [tenhishadow.pve_on_debian : set timezone] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : generate locales] * ok: [192.168.102.51] => (item=en_US.UTF-8) changed: [192.168.102.51] => (item=ru_RU.UTF-8) TASK [tenhishadow.pve_on_debian : configure chrony] * changed: [192.168.102.51] TASK [tenhishadow.pve_on_debian : start and enable chrony] * ok: [192.168.102.51] TASK [tenhishadow.pve_on_debian : configure journald] * changed: [192.168.102.51] RUNNING HANDLER [tenhishadow.pve_on_debian : restart networking] * changed: [192.168.102.51] RUNNING HANDLER [tenhishadow.pve_on_debian : restart chrony] * changed: [192.168.102.51] RUNNING HANDLER [tenhishadow.pve_on_debian : restart journald] * changed: [192.168.102.51] PLAY RECAP * 192.168.102.51 : ok=24 changed=21 unreachable=0 failed=0
- name: search for standard kernels shell: "$( which dpkg ) --get-selections linux-image* | $( which grep ) -i install | $(which awk) '{print $1}'" args: executable: /bin/bash register: standart_kernels_installed - name: remove standart kernels apt: name: "{{ item }}" state: absent with_items: "{{ standart_kernels_installed.stdout_lines|default([]) }}" - name: rebooting the server shell: nohup bash -c "sleep 2s && reboot" & async: 0 poll: 0 ignore_errors: yes register: reboot tags: reboot - name: waiting for server to come back local_action: wait_for host={{ proxmox_ip }} state=started when: reboot.changed async: 2400 poll: 10 tags: reboot
Source: https://habr.com/ru/post/342310/
All Articles