-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ehh-why-its-so-hard/fix-vega-caddy-server
feat: fix check mode for eth and core roles
- Loading branch information
Showing
15 changed files
with
253 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
- name: Install software | ||
ansible.builtin.apt: | ||
update_cache: true | ||
name: | ||
- apt-transport-https | ||
- ca-certificates | ||
- curl | ||
- software-properties-common | ||
|
||
- name: Add apt key for required repositories | ||
ansible.builtin.apt_key: | ||
url: '{{ item }}' | ||
state: present | ||
with_items: | ||
# docker | ||
- https://download.docker.com/linux/ubuntu/gpg | ||
|
||
- name: Add required source repositories into sources list | ||
ansible.builtin.apt_repository: | ||
repo: '{{ item }}' | ||
state: present | ||
with_items: | ||
- "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable" | ||
|
||
- name: Install software | ||
ansible.builtin.apt: | ||
update_cache: true | ||
name: | ||
- docker-ce | ||
- docker-ce-cli | ||
- containerd.io | ||
- docker-buildx-plugin | ||
- docker-compose-plugin | ||
|
||
- name: Restart docker | ||
ansible.builtin.systemd: | ||
state: restarted | ||
daemon_reload: true | ||
name: docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
grafana_agent_version: 0.43.0 | ||
grafana_agent_repository: grafana/agent | ||
# config template may be loaded when the lookup plugin is enabled with the following snipped "{{ lookup('file', 'configs/grafana-agent-monitoring-template.yaml') }}" | ||
# config template may be loaded when the lookup plugin is enabled with the following snipped: | ||
# "{{ lookup('file', 'configs/grafana-agent-monitoring-template.yaml') }}" | ||
grafana_agent_config_content: "# empty content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
- name: Restart grafana-agent | ||
ansible.builtin.service: | ||
name: grafana-agent | ||
state: restarted | ||
listen: Restart grafana-agent | ||
when: not ansible_check_mode | ||
when: not ansible_check_mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
pyth_price_scheduler_docker_image: public.ecr.aws/pyth-network/xc-price-pusher:v8.0.0 | ||
pyth_price_scheduler_mnemonic: "PUT_PRIVATE_KEY_HERE" | ||
pyth_price_scheduler_endpoint: "PUT_HERE_RPC_URL" | ||
pyth_price_scheduler_contract_address: "PUT_HERE_CONTRACT_ADDRESS" | ||
pyth_price_scheduler_service_endpoint: https://hermes.pyth.network | ||
pyth_price_scheduler_price_config_content: "PUT_CONFIG_HERE" | ||
|
||
pyth_price_scheduler_process_watcher_version: "v0.1.0" | ||
pyth_price_scheduler_process_watcher_repository: "vegaprotocol/process-watcher" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Process watcher | ||
ansible.builtin.import_tasks: process-watcher.yaml | ||
|
||
- name: Price pusher | ||
ansible.builtin.import_tasks: price-pusher.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
- name: Install python packages for Ansible | ||
ansible.builtin.pip: | ||
name: | ||
- docker | ||
|
||
- name: Pull an price scheduler docker image | ||
community.docker.docker_image: | ||
name: "{{- pyth_price_scheduler_docker_image -}}" | ||
source: pull | ||
pull: | ||
platform: amd64 | ||
|
||
- name: Ensure group "pyth-price-scheduler" exists | ||
ansible.builtin.group: | ||
name: pyth-price-scheduler | ||
state: present | ||
|
||
- name: Add the user "pyth-price-scheduler" | ||
ansible.builtin.user: | ||
name: pyth-price-scheduler | ||
comment: Price scheduler | ||
groups: pyth-price-scheduler,docker | ||
|
||
- name: Copy service file | ||
ansible.builtin.template: | ||
src: "lib/systemd/system/pyth-price-scheduler.service.j2" | ||
dest: "/lib/systemd/system/pyth-price-scheduler.service" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
|
||
- name: "Create config directory for the pyth-price-scheduler" | ||
ansible.builtin.file: | ||
path: "/home/pyth-price-scheduler" | ||
state: directory | ||
owner: pyth-price-scheduler | ||
group: pyth-price-scheduler | ||
mode: '0755' | ||
|
||
- name: Copy config file | ||
ansible.builtin.copy: | ||
dest: "/home/pyth-price-scheduler/price-config.yaml" | ||
content: "{{ pyth_price_scheduler_price_config_content }}" | ||
owner: pyth-price-scheduler | ||
group: pyth-price-scheduler | ||
mode: "0644" | ||
|
||
- name: Save mnemonic | ||
ansible.builtin.copy: | ||
owner: pyth-price-scheduler | ||
group: pyth-price-scheduler | ||
content: "{{- pyth_price_scheduler_mnemonic -}}" | ||
dest: /home/pyth-price-scheduler/mnemonic | ||
mode: "0644" | ||
|
||
- name: Start and enable systemd service for pyth-price-scheduler | ||
ansible.builtin.service: | ||
name: "pyth-price-scheduler" | ||
state: restarted | ||
enabled: true | ||
daemon_reload: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
- name: Download binary | ||
ansible.builtin.get_url: | ||
url: "https://github.com/{{- pyth_price_scheduler_process_watcher_repository -}}/releases/download/{{- pyth_price_scheduler_process_watcher_version -}}/process-watcher-linux-amd64.zip" # noqa: yaml[line-length] | ||
dest: &watcherdist /tmp/process-watcher.tar.gz | ||
mode: '0600' | ||
|
||
- name: Unpack binary | ||
ansible.builtin.unarchive: | ||
src: *watcherdist | ||
remote_src: true | ||
dest: /tmp | ||
|
||
- name: Copy the binary | ||
ansible.builtin.copy: | ||
remote_src: true | ||
src: "/tmp/process-watcher" | ||
dest: /usr/bin/process-watcher | ||
owner: root | ||
group: root | ||
mode: '0755' | ||
|
||
- name: Copy process watcher config | ||
ansible.builtin.template: | ||
src: "etc/pyth-process-watcher-config.toml" | ||
dest: "/etc/pyth-process-watcher-config.toml" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
|
||
- name: Copy process watcher service file | ||
ansible.builtin.template: | ||
src: "lib/systemd/system/pyth-process-watcher.service.j2" | ||
dest: "/lib/systemd/system/pyth-process-watcher.service" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
|
||
- name: Start pusher watcher service | ||
ansible.builtin.service: | ||
name: "pyth-process-watcher" | ||
state: restarted | ||
enabled: true | ||
daemon_reload: true |
23 changes: 23 additions & 0 deletions
23
roles/pyth_price_scheduler/templates/etc/pyth-process-watcher-config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[commands] | ||
# Define the log stream command | ||
log-stream = [ | ||
"/usr/bin/journalctl", | ||
"-u", "pyth-price-scheduler", | ||
"-n", "1", | ||
"-f", | ||
] | ||
# Define the command used to stop the service | ||
stop = ["/usr/bin/systemctl", "stop", "pyth-price-scheduler"] | ||
# Define the command to start the service | ||
start = ["/usr/bin/systemctl", "start", "pyth-price-scheduler"] | ||
|
||
|
||
[process-watcher] | ||
# Watches if specific docker container is running | ||
[process-watcher.docker] | ||
enabled = true | ||
container-name = "pyth-price-scheduler" | ||
|
||
[logs-watcher] | ||
# Define the keywords that trigger process restart | ||
failure-keywords = ["err", "failed", "throw err", "error"] |
31 changes: 31 additions & 0 deletions
31
roles/pyth_price_scheduler/templates/lib/systemd/system/pyth-price-scheduler.service.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[Unit] | ||
Description=Pyth price pusher | ||
Documentation=https://github.com/pyth-network/pyth-crosschain/tree/main/price_pusher | ||
After=docker.service | ||
Requires=docker.service | ||
|
||
[Service] | ||
User=pyth-price-scheduler | ||
Group=pyth-price-scheduler | ||
TimeoutStartSec=0 | ||
Restart=always | ||
ExecStop=/usr/bin/docker kill pyth-price-scheduler | ||
ExecStartPre=-/usr/bin/docker stop pyth-price-scheduler | ||
ExecStartPre=-/usr/bin/docker rm pyth-price-scheduler | ||
ExecStartPre=/usr/bin/docker pull {{ pyth_price_scheduler_docker_image }} | ||
ExecStart=/usr/bin/docker run \ | ||
--name pyth-price-scheduler \ | ||
-v /home/pyth-price-scheduler:/config \ | ||
{{ pyth_price_scheduler_docker_image }} \ | ||
npm run start -- \ | ||
evm \ | ||
--endpoint "{{- pyth_price_scheduler_endpoint -}}" \ | ||
--mnemonic-file "/config/mnemonic" \ | ||
--pyth-contract-address "{{- pyth_price_scheduler_contract_address -}}" \ | ||
--price-service-endpoint "{{- pyth_price_scheduler_service_endpoint -}}" \ | ||
--price-config-file "/config/price-config.yaml" \ | ||
--polling-frequency 5 | ||
|
||
|
||
[Install] | ||
WantedBy=multi-user.target |
17 changes: 17 additions & 0 deletions
17
roles/pyth_price_scheduler/templates/lib/systemd/system/pyth-process-watcher.service.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Unit] | ||
Description=Pyth price process watcher | ||
Documentation=https://github.com/vegaprotocol/process-watcher | ||
After=docker.service | ||
Requires=docker.service | ||
After=network.target network-online.target | ||
Requires=network-online.target | ||
|
||
[Service] | ||
User=root | ||
Group=root | ||
TimeoutStartSec=0 | ||
Restart=always | ||
ExecStart=/usr/bin/process-watcher run --config-path /etc/pyth-process-watcher-config.toml | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters