Skip to content

Commit 4d6b4ca

Browse files
committed
packer: +'sos' and 'gpu_perf_config' (limits.d)
1 parent c7b9251 commit 4d6b4ca

File tree

8 files changed

+130
-0
lines changed

8 files changed

+130
-0
lines changed

packer-rocm/playbooks/limits.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# yamllint disable rule:line-length
3+
# vim: ft=yaml.ansible
4+
- name: "Set limits.conf w/ 'gpu_perf_config' Role"
5+
hosts: all
6+
environment: # may be superfluous for your environment; mapped through Packer HCL with 'ansible_env_vars'
7+
http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}"
8+
https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}"
9+
no_proxy: "{{ lookup('ansible.builtin.env', 'no_proxy') | default(omit) }}"
10+
roles:
11+
- { role: gpu_perf_config }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* soft memlock unlimited
2+
* hard memlock unlimited
3+
* soft nofile 1048576
4+
* hard nofile 1048576
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Push configuration files
3+
become: true
4+
ansible.builtin.copy:
5+
src: "{{ item.src }}"
6+
dest: "{{ item.dest }}"
7+
mode: "{{ item.mode }}"
8+
loop:
9+
- { src: "10-sre-limits.conf", mode: "0644", dest: "/etc/security/limits.d/10-sre-limits.conf" }
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# sos
2+
3+
This role installs [sosreport](https://github.com/sosreport/sos),
4+
[xsos](https://github.com/ryran/xsos),
5+
and `extras.d` entries. Report _generation/collection_ is left as an admin activity.
6+
7+
## Variables
8+
9+
1. `sos_extras`: custom commands or files in `sos` reports.
10+
Default: see the [example playbook](#example)
11+
2. `sos_xsos`: controls [xsos](https://github.com/ryran/xsos) installation.
12+
Default: `true`
13+
3. `sos_xsos_url`: `xsos` installation URL.
14+
[Default](https://github.com/ryran/xsos/raw/master/xsos)
15+
16+
## Example
17+
18+
```yaml
19+
---
20+
- name: "'sos' role"
21+
hosts: all
22+
roles:
23+
- name: Configure 'sos', extras, and 'xsos'
24+
role: sos
25+
vars:
26+
sos_xsos_url: 'https://raw.githubusercontent.com/ryran/xsos/v0.7.33/xsos'
27+
sos_extras:
28+
amdgpu:
29+
- 'rocm-smi -a'
30+
yours:
31+
- ':/some/file/to/read'
32+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
# defaults file for sos
3+
#
4+
# dictionary of sos/related packages to install, mapped by Ansible fact (ansible_os_family)
5+
sos_pkgs:
6+
Debian: # includes derivatives (eg: Ubuntu, Mint, etc)
7+
- sosreport
8+
RedHat: # includes derivatives (eg: Fedora, Alma, etc)
9+
- sos
10+
11+
# provides '/etc/sos/extras.d' entries. expected to be provided by the user, see README for current example
12+
sos_extras: {}
13+
# sosreport examiner
14+
sos_xsos: true
15+
sos_xsos_url: "https://github.com/ryran/xsos/raw/master/xsos"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# tasks file for sos
3+
4+
- name: Install packages
5+
become: true
6+
tags: ["pkgs", "packages"]
7+
ansible.builtin.package:
8+
name: "{{ sos_pkgs[ansible_os_family] }}"
9+
update_cache: "{{ true if ansible_os_family in ['RedHat', 'Debian'] else omit }}" # these modules behind 'package' will accept this
10+
11+
- name: Install 'xsos'
12+
become: true
13+
tags: ["xsos"]
14+
when: sos_xsos is truthy(convert_bool=True)
15+
ansible.builtin.get_url:
16+
url: "{{ sos_xsos_url }}"
17+
dest: /usr/local/bin/xsos
18+
mode: "+x"
19+
20+
- name: Extras
21+
become: true
22+
tags: ["extras", "extras.d"]
23+
loop: "{{ sos_extras | dict2items }}"
24+
loop_control: { loop_var: entry }
25+
ansible.builtin.copy:
26+
dest: "/etc/sos/extras.d/{{ entry.key }}"
27+
content: "{{ entry.value | join('\n') }}"
28+
mode: "0644" # lint; suggested in case umask is restricted

packer-rocm/playbooks/sos.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# yamllint disable rule:line-length
3+
# vim: ft=yaml.ansible
4+
- name: "SOS"
5+
hosts: all
6+
environment: # may be superfluous for your environment; mapped through Packer HCL with 'ansible_env_vars'
7+
http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}"
8+
https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}"
9+
no_proxy: "{{ lookup('ansible.builtin.env', 'no_proxy') | default(omit) }}"
10+
roles:
11+
- { role: sos }

packer-rocm/ubuntu/ubuntu-rocm.pkr.hcl

+20
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ build {
7676
scripts = ["${path.root}/../packer-maas/ubuntu/scripts/curtin.sh", "${path.root}/../packer-maas/ubuntu/scripts/networking.sh", "${path.root}/../packer-maas/ubuntu/scripts/cloudimg/install-custom-kernel.sh"]
7777
}
7878

79+
provisioner "ansible" {
80+
playbook_file = "${path.root}/../playbooks/sos.yml"
81+
user = "packer"
82+
ansible_env_vars = ["http_proxy=${var.http_proxy}", "https_proxy=${var.https_proxy}", "no_proxy=${var.no_proxy}"]
83+
extra_arguments = [
84+
"-e", "ansible_python_interpreter=/usr/bin/python3",
85+
"--scp-extra-args", "'-O'"
86+
]
87+
}
88+
89+
provisioner "ansible" {
90+
playbook_file = "${path.root}/../playbooks/limits.yml"
91+
user = "packer"
92+
ansible_env_vars = ["http_proxy=${var.http_proxy}", "https_proxy=${var.https_proxy}", "no_proxy=${var.no_proxy}"]
93+
extra_arguments = [
94+
"-e", "ansible_python_interpreter=/usr/bin/python3",
95+
"--scp-extra-args", "'-O'"
96+
]
97+
}
98+
7999
provisioner "ansible" {
80100
playbook_file = "${path.root}/../playbooks/os_prep.yml"
81101
user = "packer"

0 commit comments

Comments
 (0)