Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions chatops_deployment/ansible/configure.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
---
- name: Add SSH key to agent
hosts: localhost
tags:
- key
tasks:
- name: Add SSH key
ansible.builtin.include_role:
name: add_ssh_key

- name: Configure load balancer
hosts: stack
roles:
Expand Down Expand Up @@ -35,6 +44,14 @@
tags:
- grafana

- name: Attach volume
hosts: stack
gather_facts: true
roles:
- volume
tags:
- volume

- name: Configure Prometheus
hosts: stack
roles:
Expand Down
9 changes: 8 additions & 1 deletion chatops_deployment/ansible/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
name: terraform
tasks_from: deploy

- name: Add known hosts of bastion host and private VMs
- name: Add SSH key to agent
hosts: localhost
tasks:
- name: Add SSH key
ansible.builtin.include_role:
name: add_ssh_key

- name: Add known host of stack VM
hosts: localhost
gather_facts: false
roles:
Expand Down
26 changes: 26 additions & 0 deletions chatops_deployment/ansible/roles/add_ssh_key/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Install expect
become: true
ansible.builtin.apt:
name: expect
update_cache: true

- name: Start ssh-agent
# noqa: command-instead-of-shell
# interpolation is not supported by the command module
ansible.builtin.shell: 'eval $("ssh-agent -s")'
register: add_ssh_key_start_agent
changed_when: add_ssh_key_start_agent.rc == 0

- name: Add key to ssh-agent
# noqa: command-instead-of-shell
# We must use shell here as here-docs don't work with command
ansible.builtin.shell: |
expect << EOF
spawn ssh-add {{ env }}-bastion-key
expect "Enter passphrase for {{ env }}-bastion-key:"
send "{{ bastion_key_passphrase }}\r"
expect eof
EOF
register: add_ssh_key_add_key
changed_when: add_ssh_key_add_key.rc == 0
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
path:
data: /var/elasticsearch/data
data: /var/stack/elasticsearch/data
logs: /var/log/elasticsearch
cluster.name: chatops-elasticsearch
xpack.security.enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,10 @@
state: latest # noqa: package-latest
update_cache: true

- name: Attach data volume to Elasticsearch data directory
become: true
ansible.posix.mount:
boot: true
path: /var/elasticsearch/data
src: "{{ elasticsearch_device }}"
state: mounted
fstype: ext4

- name: Set permissions on volume
become: true
ansible.builtin.file:
path: /var/elasticsearch/data
path: /var/stack/elasticsearch/data
state: directory
owner: root
group: elasticsearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Group=prometheus
Restart=on-failure
ExecStart=/opt/prometheus/prometheus \
--config.file=/opt/prometheus/prometheus.yml \
--storage.tsdb.path=/opt/prometheus/data \
--storage.tsdb.path=/var/stack/prometheus/data \
--storage.tsdb.retention.time=30d \
--web.config.file=/opt/prometheus/web.yml
StandardOutput=append:/var/log/prometheus/prometheus.log
Expand Down
13 changes: 4 additions & 9 deletions chatops_deployment/ansible/roles/prometheus/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,18 @@
- Move Prometheus binaries
- Start Prometheus

- name: Attach volume to Prometheus data directory
become: true
ansible.posix.mount:
boot: true
path: /var/prometheus/data
src: "{{ prometheus_device }}"
state: mounted
fstype: ext4
- name: Flush handlers to move binaries
ansible.builtin.meta: flush_handlers

- name: Set permissions on volume
become: true
ansible.builtin.file:
path: /var/prometheus/data
path: /var/stack/prometheus/data
state: directory
owner: prometheus
group: prometheus
mode: "0774"
recurse: true

- name: Copy prometheus service file
become: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
- name: Download and extract systemd-exporter
become: true
ansible.builtin.unarchive:
src: "https://github.com/prometheus-community/systemd_exporter/releases/download/v{{ systemd_exporter_version }}/systemd_exporter-{{ systemd_exporter_version
}}.linux-amd64.tar.gz"
src: "https://github.com/prometheus-community/systemd_exporter/releases/download/v{{ systemd_exporter_version }}/
systemd_exporter-{{ systemd_exporter_version}}.linux-amd64.tar.gz"
dest: /tmp
remote_src: true
creates: "/tmp/systemd_exporter-{{ systemd_exporter_version }}.linux-amd64"
Expand Down
18 changes: 18 additions & 0 deletions chatops_deployment/ansible/roles/volume/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Attach volume to stack host
become: true
ansible.posix.mount:
boot: true
path: /var/stack
src: "{{ ansible_local.terraform.vars.stack_device }}"
state: mounted
fstype: ext4

- name: Set permissions
become: true
ansible.builtin.file:
state: directory
path: /var/stack
owner: ubuntu
group: ubuntu
mode: "0775"
Loading