diff --git a/CLAUDE.md b/CLAUDE.md index 7d01b64..bb5f635 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -21,3 +21,20 @@ You are encouraged to explore the zk, follow links, and propose updates to it as - **Homebrew services**: `brew services start|stop|restart ` - **Non-homebrew services**: use `mcquack` (LaunchAgent manager for macOS) + +## Ansible + +Run playbooks from the `ansible/` directory. + +```bash +# Install collection dependencies +ansible-galaxy collection install -r requirements.yml + +# Dry-run before committing changes +ansible-playbook playbooks/indri.yml --check --diff + +# Apply changes +ansible-playbook playbooks/indri.yml +``` + +**Always dry-run (`--check --diff`) ansible changes before committing.** diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..d888f5b --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,7 @@ +[defaults] +inventory = inventory/hosts.yml +roles_path = roles +host_key_checking = False + +[privilege_escalation] +become = False diff --git a/ansible/inventory/hosts.yml b/ansible/inventory/hosts.yml new file mode 100644 index 0000000..645c67a --- /dev/null +++ b/ansible/inventory/hosts.yml @@ -0,0 +1,14 @@ +all: + children: + servers: + hosts: + indri: + ansible_host: indri + workstations: + hosts: + gilbert: + ansible_host: gilbert + nas: + hosts: + sifaka: + ansible_host: sifaka diff --git a/ansible/playbooks/indri.yml b/ansible/playbooks/indri.yml new file mode 100644 index 0000000..ae51806 --- /dev/null +++ b/ansible/playbooks/indri.yml @@ -0,0 +1,6 @@ +--- +- name: Configure indri + hosts: indri + roles: + - prometheus + - grafana diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..afc836d --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1,3 @@ +--- +collections: + - name: community.general diff --git a/ansible/roles/grafana/handlers/main.yml b/ansible/roles/grafana/handlers/main.yml new file mode 100644 index 0000000..a2ce139 --- /dev/null +++ b/ansible/roles/grafana/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart grafana + ansible.builtin.command: brew services restart grafana diff --git a/ansible/roles/grafana/tasks/main.yml b/ansible/roles/grafana/tasks/main.yml new file mode 100644 index 0000000..3339aee --- /dev/null +++ b/ansible/roles/grafana/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: Install grafana via homebrew + community.general.homebrew: + name: grafana + state: present + +- name: Ensure grafana service is started + ansible.builtin.command: brew services start grafana + register: brew_start + changed_when: "'Successfully started' in brew_start.stdout" + failed_when: false diff --git a/ansible/roles/prometheus/handlers/main.yml b/ansible/roles/prometheus/handlers/main.yml new file mode 100644 index 0000000..996ba18 --- /dev/null +++ b/ansible/roles/prometheus/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart prometheus + ansible.builtin.command: brew services restart prometheus diff --git a/ansible/roles/prometheus/tasks/main.yml b/ansible/roles/prometheus/tasks/main.yml new file mode 100644 index 0000000..150c8ef --- /dev/null +++ b/ansible/roles/prometheus/tasks/main.yml @@ -0,0 +1,25 @@ +--- +- name: Install prometheus via homebrew + community.general.homebrew: + name: prometheus + state: present + +- name: Configure prometheus.yml + ansible.builtin.template: + src: prometheus.yml.j2 + dest: /opt/homebrew/etc/prometheus.yml + mode: '0644' + notify: restart prometheus + +- name: Configure prometheus.args + ansible.builtin.template: + src: prometheus.args.j2 + dest: /opt/homebrew/etc/prometheus.args + mode: '0644' + notify: restart prometheus + +- name: Ensure prometheus service is started + ansible.builtin.command: brew services start prometheus + register: brew_start + changed_when: "'Successfully started' in brew_start.stdout" + failed_when: false diff --git a/ansible/roles/prometheus/templates/prometheus.args.j2 b/ansible/roles/prometheus/templates/prometheus.args.j2 new file mode 100644 index 0000000..fcfb758 --- /dev/null +++ b/ansible/roles/prometheus/templates/prometheus.args.j2 @@ -0,0 +1,3 @@ +--config.file /opt/homebrew/etc/prometheus.yml +--web.listen-address=0.0.0.0:9090 +--storage.tsdb.path /opt/homebrew/var/prometheus diff --git a/ansible/roles/prometheus/templates/prometheus.yml.j2 b/ansible/roles/prometheus/templates/prometheus.yml.j2 new file mode 100644 index 0000000..2a82a87 --- /dev/null +++ b/ansible/roles/prometheus/templates/prometheus.yml.j2 @@ -0,0 +1,14 @@ +global: + scrape_interval: 15s + +scrape_configs: + - job_name: "node-exporter-indri" + static_configs: + - targets: ["localhost:9090"] + - targets: ["localhost:9100"] + relabel_configs: + - target_label: instance + replacement: indri + - job_name: "node-exporter-sifaka" + static_configs: + - targets: ["sifaka:9100"]