commit 133692dcb44d7e18d0af02bd71b444f6044d5d58 Author: heimoshuiyu Date: Fri Jun 14 10:38:25 2024 +0800 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..4815a63 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# My Ansible Scripts diff --git a/disable-cpu-boost.yaml b/disable-cpu-boost.yaml new file mode 100644 index 0000000..e5f9ae1 --- /dev/null +++ b/disable-cpu-boost.yaml @@ -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]" diff --git a/enable-cpu-boost.yaml b/enable-cpu-boost.yaml new file mode 100644 index 0000000..0263811 --- /dev/null +++ b/enable-cpu-boost.yaml @@ -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]" diff --git a/install-ipmi-exporter.yaml b/install-ipmi-exporter.yaml new file mode 100644 index 0000000..f0cfa6a --- /dev/null +++ b/install-ipmi-exporter.yaml @@ -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 + diff --git a/install-node-exporter.yaml b/install-node-exporter.yaml new file mode 100644 index 0000000..e6164e2 --- /dev/null +++ b/install-node-exporter.yaml @@ -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 + diff --git a/install-systemd-oomd.yaml b/install-systemd-oomd.yaml new file mode 100644 index 0000000..7a77995 --- /dev/null +++ b/install-systemd-oomd.yaml @@ -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 diff --git a/inventory.ini b/inventory.ini new file mode 100644 index 0000000..b654ac6 --- /dev/null +++ b/inventory.ini @@ -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 + diff --git a/kill-msw.yaml b/kill-msw.yaml new file mode 100644 index 0000000..a38ffa3 --- /dev/null +++ b/kill-msw.yaml @@ -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 diff --git a/update-gateway.yaml b/update-gateway.yaml new file mode 100644 index 0000000..d6dec4f --- /dev/null +++ b/update-gateway.yaml @@ -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 }}