Skip to content

Commit

Permalink
feat(system_info): add role (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadNews authored Jun 29, 2024
1 parent b5b538f commit 895ee00
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 32 deletions.
12 changes: 5 additions & 7 deletions roles/aptup/molecule/aptup/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
hosts: all
become: true

tasks:
- name: Test role
ansible.builtin.import_role:
name: deadnews.util.aptup
vars:
aptup_next_release: false
aptup_show_stdout: true
roles:
- role: deadnews.util.system_info
- role: deadnews.util.aptup
aptup_next_release: false
aptup_show_stdout: true
13 changes: 6 additions & 7 deletions roles/aptup/molecule/aptup_vagrant/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
hosts: all
become: true

tasks:
- name: Test role
ansible.builtin.import_role:
name: deadnews.util.aptup
vars:
aptup_next_release: true
aptup_next_release_update_grub: false
roles:
- role: deadnews.util.system_info
- role: deadnews.util.aptup
aptup_next_release: true
aptup_show_stdout: true
aptup_next_release_update_grub: false
16 changes: 7 additions & 9 deletions roles/docker/molecule/docker/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
hosts: all
become: true

tasks:
- name: Install Docker
ansible.builtin.import_role:
name: deadnews.util.docker
vars:
docker_rootless: true
docker_config: files/config.json
docker_config_daemon: files/daemon.json
docker_config_systemd: templates/proxy.conf.j2
roles:
- role: deadnews.util.system_info
- role: deadnews.util.docker
docker_rootless: true
docker_config: files/config.json
docker_config_daemon: files/daemon.json
docker_config_systemd: templates/proxy.conf.j2
16 changes: 7 additions & 9 deletions roles/docker/molecule/docker_vagrant/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
hosts: all
become: true

tasks:
- name: Test role
ansible.builtin.import_role:
name: deadnews.util.docker
vars:
docker_rootless: true
docker_rootless_expose_privileged_ports: true
docker_cleanup_scheduled: true
docker_hold_packages: true
roles:
- role: deadnews.util.system_info
- role: deadnews.util.docker
docker_rootless: true
docker_rootless_expose_privileged_ports: true
docker_cleanup_scheduled: true
docker_hold_packages: true
4 changes: 4 additions & 0 deletions roles/docker_compose/molecule/docker_compose/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
become: true

tasks:
- name: Show system info
ansible.builtin.import_role:
name: deadnews.util.system_info

- name: Install Docker
ansible.builtin.import_role:
name: deadnews.util.docker
Expand Down
8 changes: 8 additions & 0 deletions roles/reboot/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# deadnews.util.reboot

> Reboot machine if nedeed
## Example Playbook

```yaml
- hosts: servers
roles:
- role: deadnews.util.reboot
```
11 changes: 11 additions & 0 deletions roles/system_info/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# deadnews.util.system_info

> Show system info
## Example Playbook

```yaml
- hosts: servers
roles:
- role: deadnews.util.system_info
```
6 changes: 6 additions & 0 deletions roles/system_info/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
galaxy_info:
author: DeadNews
description: Show system info
license: MIT
min_ansible_version: 2.16.0
20 changes: 20 additions & 0 deletions roles/system_info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# Show system info

- name: Show system info (can be cashed)
ansible.builtin.debug:
msg: |
Hostname: {{ ansible_hostname }}
System: {{ ansible_distribution }} {{ ansible_distribution_version }} {{ ansible_distribution_release }}
Kernel: {{ ansible_kernel }}
Python: {{ ansible_python_version }}
Product: {{ ansible_product_name }}
CPUs: {{ ansible_processor_count }} × {{ ansible_processor[2] }}
Cores: {{ ansible_processor_nproc }} cores, {{ ansible_processor_nproc * ansible_processor_threads_per_core }} threads
Memory: {{ (ansible_memtotal_mb / 1024) | round(2) }} GiB
Uptime: {{
(ansible_uptime_seconds // 86400) | string + 'd ' +
((ansible_uptime_seconds // 3600) % 24) | string + 'h ' +
((ansible_uptime_seconds // 60) % 60) | string + 'm ' +
(ansible_uptime_seconds % 60) | string + 's'
}}
4 changes: 4 additions & 0 deletions roles/wireguard/molecule/wireguard/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
wireguard_publickey_peer: iEuV0dLE9OYfZzoKYrHZBK6Hzr/8dn1aovDuUrt9/g8= # gitleaks:allow

tasks:
- name: Show system info
ansible.builtin.include_role:
name: deadnews.util.system_info

- name: Install iptables
ansible.builtin.apt:
name: iptables
Expand Down

0 comments on commit 895ee00

Please sign in to comment.