upload
commit
56a1c65d4b
|
@ -0,0 +1,5 @@
|
|||
#inventory
|
||||
[test]
|
||||
192.168.251.104 ansible_connection=ssh ansible_ssh_user=one ansible_ssh_pass=wimark ansible_sudo_pass=wimark second_disk=sdb adjacent_partition=sda
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
- name: Disable C-state for all CPUs
|
||||
command: |
|
||||
echo 'options processor max_cstate=1' >> /etc/default/grub
|
||||
register: disable_cstate_result
|
||||
ignore_errors: true # Игнорируем ошибки, чтобы продолжить выполнение
|
||||
changed_when: disable_cstate_result.rc == 0 # Установка состояния измененного, если код возврата 0
|
||||
|
||||
- name: Check result of disabling C-state
|
||||
debug:
|
||||
msg: "Disable C-state command executed successfully."
|
||||
when: disable_cstate_result.rc == 0
|
||||
|
||||
- name: Check for errors in disabling C-state
|
||||
debug:
|
||||
msg: "Error disabling C-state: {{ disable_cstate_result.stderr }}"
|
||||
when: disable_cstate_result.rc != 0
|
||||
|
||||
- name: Update grub configuration
|
||||
command: update-grub
|
||||
register: update_grub_result
|
||||
ignore_errors: true # Игнорируем ошибки, чтобы продолжить выполнение
|
||||
|
||||
- name: Check result of updating grub
|
||||
debug:
|
||||
msg: "Grub updated successfully."
|
||||
when: update_grub_result.rc == 0
|
||||
|
||||
- name: Check for errors in updating grub
|
||||
debug:
|
||||
msg: "Error updating grub: {{ update_grub_result.stderr }}"
|
||||
when: update_grub_result.rc != 0
|
||||
|
||||
- name: Switch CPU operation to performance mode
|
||||
ansible.builtin.shell: |
|
||||
for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
|
||||
echo "performance" > "$cpu";
|
||||
done
|
||||
register: switch_cpu_mode
|
||||
failed_when: switch_cpu_mode.rc != 0
|
||||
when: switch_cpu_mode is not skipped
|
||||
changed_when: switch_cpu_mode.rc == 0
|
||||
ignore_errors: true
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- name: Encrypt second disk
|
||||
ansible.builtin.shell: |
|
||||
echo -n "your_passphrase" | cryptsetup luksFormat /dev/{{ second_disk }} --key-file=-
|
||||
ignore_errors: true
|
||||
|
||||
- name: Open encrypted second disk
|
||||
ansible.builtin.shell: |
|
||||
echo -n "your_passphrase" | cryptsetup luksOpen /dev/{{ second_disk }} crypt_second_disk --key-file=-
|
||||
ignore_errors: true
|
||||
register: second_disk_status
|
||||
|
||||
- name: Format the encrypted second disk
|
||||
command: mkfs.ext4 /dev/mapper/crypt_second_disk
|
||||
when: second_disk_status.rc == 0
|
||||
|
||||
- name: Ensure the mount point exists
|
||||
file:
|
||||
path: /mnt/encrypted_disk
|
||||
state: directory
|
||||
|
||||
- name: Mount the encrypted second disk
|
||||
mount:
|
||||
path: /mnt/encrypted_disk
|
||||
src: /dev/mapper/crypt_second_disk
|
||||
fstype: ext4
|
||||
state: mounted
|
|
@ -0,0 +1,4 @@
|
|||
- include_tasks: encrypt_disks.yml
|
||||
- include_tasks: cpu_configuration.yml
|
||||
- include_tasks: network_configuration.yml
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
- name: Rename network interface to net0
|
||||
ansible.builtin.shell: ip link set dev {{ ansible_default_ipv4.interface }} name net0; netplan apply
|
||||
register: rename_interface
|
||||
failed_when: rename_interface.rc != 0
|
||||
|
||||
- name: Display renamed network interface
|
||||
ansible.builtin.debug:
|
||||
msg: "Renamed network interface: net0"
|
||||
|
Loading…
Reference in New Issue