This commit is contained in:
2024-06-14 10:38:25 +08:00
commit 133692dcb4
9 changed files with 159 additions and 0 deletions

1
README.md Normal file
View File

@@ -0,0 +1 @@
# My Ansible Scripts

16
disable-cpu-boost.yaml Normal file
View File

@@ -0,0 +1,16 @@
- name: Disable CPU Boost on Linux Servers
hosts: all
become: yes
user: root
tasks:
- name: Gather facts
setup:
filter: ansible_processor*
- name: Disable CPU boost for AMD processors
shell: echo 0 > /sys/devices/system/cpu/cpufreq/boost
when: "'AuthenticAMD' in ansible_processor[1]"
- name: Disable CPU boost for Intel processors
shell: echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
when: "'GenuineIntel' in ansible_processor[1]"

16
enable-cpu-boost.yaml Normal file
View File

@@ -0,0 +1,16 @@
- name: Enable CPU Boost on Linux Servers
hosts: all
become: yes
user: root
tasks:
- name: Gather facts
setup:
filter: ansible_processor*
- name: Enable CPU boost for AMD processors
shell: echo 1 > /sys/devices/system/cpu/cpufreq/boost
when: "'AuthenticAMD' in ansible_processor[1]"
- name: Enable CPU boost for Intel processors
shell: echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo
when: "'GenuineIntel' in ansible_processor[1]"

View File

@@ -0,0 +1,35 @@
- name: Install ipmi-from IPFS gateway
hosts: all
become: yes
user: root
tasks:
- name: Ensure ipmitool is installed
apt:
name: ipmitool
state: present
- name: Ensure freeipmi is installed
apt:
name: freeipmi
state: present
- name: Download the deb file from IPFS gateway
get_url:
url: http://192.168.1.13:8080/ipfs/QmXAvSfitFCGw2N4YC3R8sJd6dBBhW21rCRhvEpzyfjGW9
dest: /tmp/ipmi-exporter.deb
- name: Install the deb package
apt:
deb: /tmp/ipmi-exporter.deb
- name: Clean up the deb file
file:
path: /tmp/ipmi-exporter
state: absent
- name: Ensure ipmi-exporter service is enabled and started
systemd:
name: ipmi-exporter
enabled: yes
state: started

View File

@@ -0,0 +1,25 @@
- name: Install node-exporter from IPFS gateway
hosts: all
become: yes
user: root
tasks:
- name: Download the deb file from IPFS gateway
get_url:
url: http://192.168.1.13:8080/ipfs/QmeexpjtcrKDQhFdvMyVqQuBf7fNVurkzC1YWkFFDumDgj
dest: /tmp/node-exporter.deb
- name: Install the deb package
apt:
deb: /tmp/node-exporter.deb
- name: Clean up the deb file
file:
path: /tmp/node-exporter
state: absent
- name: Ensure node-exporter service is enabled and started
systemd:
name: node-exporter
enabled: yes
state: started

15
install-systemd-oomd.yaml Normal file
View File

@@ -0,0 +1,15 @@
- name: Install ipmi-from IPFS gateway
hosts: all
become: yes
user: root
tasks:
- name: Ensure systemd-oomd is installed
apt:
name: systemd-oomd
state: present
- name: Ensure systemd-oomd service is enabled and started
systemd:
name: systemd-oomd
enabled: yes
state: started

22
inventory.ini Normal file
View File

@@ -0,0 +1,22 @@
[waykey]
192.168.1.2
192.168.1.3
192.168.1.11
192.168.1.13
192.168.1.15
192.168.1.19
192.168.1.20
192.168.1.32
192.168.1.33
192.168.1.34
192.168.1.35
192.168.1.36
192.168.1.37
192.168.1.42
192.168.1.43
192.168.1.44
192.168.1.47
192.168.1.48
192.168.1.49
192.168.1.91

13
kill-msw.yaml Normal file
View File

@@ -0,0 +1,13 @@
- name: Kill all "msw" processes
hosts: all
become: yes
user: root
tasks:
- name: Kill all "msw" processes
ansible.builtin.shell: "pkill -f msw"
ignore_errors: yes
register: result
- name: Display result
debug:
var: result

16
update-gateway.yaml Normal file
View File

@@ -0,0 +1,16 @@
- name: Update default route
hosts: all
become: yes
user: root
vars_prompt:
- name: "gateway_ip"
prompt: "Enter the gateway IP address"
private: no
tasks:
- name: Delete the default route
command: ip route delete default
ignore_errors: yes # Ignore errors in case the default route does not exist
- name: Add the new default route
command: ip route add default via {{ gateway_ip }}