Skip to content

Commit e5211fa

Browse files
committed
[Infra] Fix node ansible playbook
Signed-off-by: Herklos <herklos@drakkar.software>
1 parent 37e5e67 commit e5211fa

6 files changed

Lines changed: 35 additions & 10 deletions

File tree

infra/node/ansible/roles/common/tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
---
2+
- name: Ensure deploy user exists
3+
ansible.builtin.user:
4+
name: deploy
5+
system: true
6+
create_home: false
7+
shell: /usr/sbin/nologin
8+
29
- name: Check if Docker iptables chains are present
310
ansible.builtin.command: iptables -L DOCKER-USER -n
411
register: docker_chains

infra/node/ansible/roles/octobot/tasks/healthcheck.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,26 @@
1212
changed_when: false
1313
when: enable_replica_mode | default(false) | bool and is_master | default(false) | bool
1414

15-
- name: Wait for OctoBot Node health
15+
- name: Wait for OctoBot Node API health
16+
ansible.builtin.uri:
17+
url: "http://127.0.0.1:{{ octobot_node_port }}/api/v1/openapi.json"
18+
return_content: true
19+
status_code: [200]
20+
register: octobot_health
21+
until: octobot_health.status == 200
22+
retries: 60
23+
delay: 5
24+
25+
- name: Wait for OctoBot Web UI health
1626
ansible.builtin.uri:
1727
url: "http://127.0.0.1:{{ octobot_web_port }}"
1828
return_content: true
1929
status_code: [200, 302]
20-
register: octobot_health
21-
until: octobot_health.status in [200, 302]
22-
retries: 30
30+
register: web_health
31+
until: web_health.status in [200, 302]
32+
retries: 60
2333
delay: 5
34+
when: expose_web_ui | default(false) | bool
2435

2536
- name: Wait for Nginx health (proxied)
2637
ansible.builtin.uri:
@@ -31,4 +42,4 @@
3142
until: nginx_health.status == 200
3243
retries: 10
3344
delay: 5
34-
when: enable_nginx | default(false)
45+
when: enable_nginx | default(false) | bool

infra/node/ansible/roles/octobot/tasks/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
group: deploy
2828
mode: "0644"
2929
notify: restart nginx
30-
when: enable_nginx | default(false)
30+
when: enable_nginx | default(false) | bool
3131

3232
- name: Copy Tor proxy Dockerfile
3333
ansible.builtin.copy:
@@ -37,7 +37,7 @@
3737
group: deploy
3838
mode: "0644"
3939
notify: restart tor
40-
when: enable_tor | default(false)
40+
when: enable_tor | default(false) | bool
4141

4242
- name: Generate self-signed TLS certificate
4343
ansible.builtin.command:
@@ -48,11 +48,11 @@
4848
-subj "/CN={{ inventory_hostname | regex_replace('[^a-zA-Z0-9.\\-]', '') }}"
4949
creates: "{{ stack_deploy_dir }}/origin.crt"
5050
notify: restart nginx
51-
when: enable_nginx | default(false)
51+
when: enable_nginx | default(false) | bool
5252

5353
- name: Pull Docker images
5454
ansible.builtin.command:
55-
cmd: docker compose pull --ignore-buildable
55+
cmd: docker compose pull --ignore-buildable --ignore-pull-failures
5656
chdir: "{{ stack_deploy_dir }}"
5757
changed_when: false
5858

infra/node/ansible/roles/octobot/templates/env.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Node API (env var override for NodeApiService.get_is_enabled)
2+
ENABLE_NODE_API=true
3+
14
NODE_ENVIRONMENT=production
25
IS_MASTER_MODE={{ 'true' if (is_master | default(false) | bool) else 'false' }}
36
CONSUMER_ONLY={{ 'true' if (is_consumer_only | default(false) | bool) else 'false' }}

packages/services/octobot_services/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
CONFIG_NODE_API_PORT = "port"
7373
ENV_NODE_API_PORT = "NODE_API_PORT"
7474
ENV_NODE_API_ADDRESS = "NODE_API_ADDRESS"
75+
ENV_ENABLE_NODE_API = "ENABLE_NODE_API"
7576
DEFAULT_NODE_API_IP = DEFAULT_SERVER_IP
7677
DEFAULT_NODE_API_PORT = 8000
7778

packages/tentacles/Services/Services_bases/node_api_service/node_api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def is_setup_correctly(config):
7575

7676
@staticmethod
7777
def get_is_enabled(config):
78-
# allow to disable node api interface from config, enabled by default otherwise
78+
if os.getenv(services_constants.ENV_ENABLE_NODE_API):
79+
return commons_constants.parse_boolean_environment_var(
80+
services_constants.ENV_ENABLE_NODE_API, "false"
81+
)
7982
return config.get(services_constants.CONFIG_CATEGORY_SERVICES, {}).get(services_constants.CONFIG_NODE_API, {}).get(
8083
commons_constants.CONFIG_ENABLED_OPTION, False
8184
)

0 commit comments

Comments
 (0)