Execution
Date
22 Apr 2026 12:55:22 +0100
Duration
00:00:53.65
Controller
ssh-gw-4.layershift.com
User
root
Versions
Ansible
2.16.13
ara
1.7.5 / 1.7.5
Python
3.10.10
Summary
1
Hosts
14
Tasks
14
Results
1
Plays
1
Files
0
Records
File: /home/ssh-gateway/ansible/kuly/kvm_node_install/setup_new_node.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | --- - name: New KVM server provisioning scripts hosts: all gather_facts: true vars: agent360_api_key: "6225dd3b2c8afd50166ae988" firewall_mode: "HARDWARE_NODE" timezone: "UTC" swap_file_path: "/var/lib/libvirt/swapfile" swap_file_size: "2G" main_server_ip: "{{ ansible_default_ipv4.address }}" monitoring_script_url: "https://monitoring.platform360.io/agent360.sh" kernelcare_installer_url: "https://kernelcare.com/installer" firewall360_install_url: "https://tgz.thecode.casa/firewall360/install.sh" firewall360_reset_url: "https://deploy.thecode.casa/firewall360/reset_firewall.sh" agent360_plugins_tgz_url: "https://tgz.thecode.casa/agent360_plugins/install.sh" agent360_plugins_deploy_url: "https://deploy.thecode.casa/agent360_plugins/install.sh" virtnbdbackup_install_url: "https://tgz.thecode.casa/virtnbdbackup/install.sh" backup_manager_install_url: "https://backup-manager.vm.plesk-server.com/agents/install" tasks: # ======================================================================== # 1. SWAP FILE SETUP # ======================================================================== - name: Create swap file directory if missing ansible.builtin.file: path: "{{ swap_file_path | dirname }}" state: directory mode: '0755' tags: [swap, prep] - name: Create swap file ansible.builtin.command: "fallocate -l {{ swap_file_size }} {{ swap_file_path }}" args: creates: "{{ swap_file_path }}" tags: [swap, prep] - name: Set secure permissions (600) on swap file ansible.builtin.file: path: "{{ swap_file_path }}" mode: '0600' tags: [swap, prep] - name: Initialize swap area ansible.builtin.command: "mkswap {{ swap_file_path }}" args: creates: "{{ swap_file_path }}.initialized" notify: Mark swap as initialized tags: [swap, prep] - name: Enable swap file immediately ansible.builtin.command: "swapon {{ swap_file_path }}" register: swapon_result changed_when: "'already active' not in swapon_result.stderr" failed_when: swapon_result.rc != 0 and 'already active' not in swapon_result.stderr tags: [swap, prep] - name: Enable all swaps from /etc/fstab (swapon -av) ansible.builtin.command: "swapon -av" register: swapon_av changed_when: false tags: [swap, prep] - name: Ensure swap entry exists in /etc/fstab ansible.builtin.lineinfile: path: /etc/fstab line: "{{ swap_file_path }} none swap sw 0 0" regexp: "^{{ swap_file_path }}\\s+none\\s+swap" state: present validate: 'findmnt -T %s' tags: [swap, prep, fstab] # ======================================================================== # 2. TIMEZONE CONFIGURATION # ======================================================================== - name: Set system timezone to {{ timezone }} community.general.timezone: name: "{{ timezone }}" tags: [config, timezone] # ======================================================================== # 3. KERNELCARE INSTALLATION # ======================================================================== - name: Install KernelCare ansible.builtin.shell: | set -o pipefail curl -s -L {{ kernelcare_installer_url }} | bash args: executable: /bin/bash creates: /usr/bin/kcare register: kernelcare_install changed_when: kernelcare_install.rc == 0 tags: [kernelcare, security] - name: Enable and start KernelCare service ansible.builtin.systemd: name: kcare enabled: true state: started daemon_reload: true tags: [kernelcare, security] - name: Display KernelCare licensing reminder ansible.builtin.debug: msg: | ⚠️ KERNELCARE LICENSE REMINDER ⚠️ Please license this IP in your KernelCare portal: → {{ main_server_ip }} Visit: https://kernelcare.com/client-area tags: [kernelcare, reminder] # ======================================================================== # 4. FIREWALL360 INSTALLATION (with mode input) # ======================================================================== - name: Install Firewall360 ansible.builtin.shell: "bash <(curl -sL {{ firewall360_install_url }}) <<< '{{ firewall_mode }}'" args: executable: /bin/bash register: firewall_install changed_when: firewall_install.rc == 0 tags: [firewall, security] # ======================================================================== # 5. FIREWALL360 RESET # ======================================================================== - name: Reset Firewall360 configuration ansible.builtin.shell: "bash <(curl -sL {{ firewall360_reset_url }})" args: executable: /bin/bash register: firewall_reset changed_when: firewall_reset.rc == 0 tags: [firewall, security] # ======================================================================== # 6. AGENT360 MONITORING INSTALLATION # ======================================================================== - name: Download Agent360 installation script ansible.builtin.get_url: url: "{{ monitoring_script_url }}" dest: /tmp/agent360.sh mode: '0755' timeout: 30 tags: [monitoring, agent360] - name: Install Agent360 monitoring agent ansible.builtin.shell: | set -o pipefail bash /tmp/agent360.sh {{ agent360_api_key }} args: chdir: /tmp register: agent360_install changed_when: agent360_install.rc == 0 tags: [monitoring, agent360] # ======================================================================== # 7. AGENT360 CUSTOM PLUGINS # ======================================================================== - name: Install plugin internal_server_metrics ansible.builtin.shell: | set -o pipefail curl -Ls {{ agent360_plugins_tgz_url }} | bash -s internal_server_metrics args: executable: /bin/bash register: plugin_internal changed_when: plugin_internal.rc == 0 tags: [monitoring, plugins] - name: Install plugin vrrp_mon_cr ansible.builtin.shell: | set -o pipefail curl -Ls {{ agent360_plugins_deploy_url }} | bash -s vrrp_mon_cr args: executable: /bin/bash register: plugin_vrrp changed_when: plugin_vrrp.rc == 0 tags: [monitoring, plugins] - name: Install plugin mdstat_ls ansible.builtin.shell: | set -o pipefail curl -Ls {{ agent360_plugins_deploy_url }} | bash -s mdstat_ls args: executable: /bin/bash register: plugin_mdstat changed_when: plugin_mdstat.rc == 0 tags: [monitoring, plugins] # ======================================================================== # 8. NBD MODULE + VIRTNBDBACKUP # ======================================================================== - name: Ensure NBD module loads at boot ansible.builtin.copy: content: "nbd\n" dest: /etc/modules-load.d/nbd.conf mode: '0644' tags: [backup, nbd, prep] - name: Load NBD kernel module immediately community.general.modprobe: name: nbd state: present tags: [backup, nbd, prep] - name: Install virtnbdbackup ansible.builtin.shell: | set -o pipefail curl -s {{ virtnbdbackup_install_url }} | bash args: executable: /bin/bash register: virtnbd_install changed_when: virtnbd_install.rc == 0 tags: [backup, virtnbd] # ======================================================================== # 9. BACKUP-MANAGER INSTALLATION # ======================================================================== - name: Download backup-manager installer ansible.builtin.get_url: url: "{{ backup_manager_install_url }}" dest: /tmp/installer.sh mode: '0755' timeout: 30 tags: [backup, backup-manager] - name: Run backup-manager installer (pass 1) ansible.builtin.shell: | set -o pipefail /tmp/installer.sh args: chdir: /tmp register: backup_install_1 changed_when: backup_install_1.rc == 0 tags: [backup, backup-manager] - name: Run backup-manager installer (pass 2) ansible.builtin.shell: | set -o pipefail /tmp/installer.sh args: chdir: /tmp register: backup_install_2 changed_when: backup_install_2.rc == 0 tags: [backup, backup-manager] - name: Run backup-manager mount script ansible.builtin.shell: | set -o pipefail /tmp/mount.sh args: chdir: /tmp register: backup_mount changed_when: backup_mount.rc == 0 tags: [backup, backup-manager] # ======================================================================== # 10. POST-INSTALL SUMMARY # ======================================================================== - name: Display provisioning completion summary ansible.builtin.debug: msg: | ✅ SERVER PROVISIONING COMPLETE ✅ Configuration applied: • Swap: {{ swap_file_path }} ({{ swap_file_size }}) → active • Timezone: {{ timezone }} • KernelCare: installed (license IP: {{ main_server_ip }}) • Firewall360: {{ firewall_mode }} mode + reset • Agent360: monitoring + 3 plugins installed • NBD/virtnbdbackup: ready • backup-manager: installed + mounted Quick verification commands: swapon --show timedatectl systemctl status kcare firewall360 status agent360 status lsmod | grep nbd tags: [verify, always] handlers: - name: Mark swap as initialized ansible.builtin.file: path: "{{ swap_file_path }}.initialized" state: touch mode: '0644' |