Skip to content

Commit

Permalink
feat: add playbook for generating public node nginx config
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Dec 12, 2023
1 parent df00b8c commit 362ef59
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
37 changes: 37 additions & 0 deletions playbooks/fullnode/10-public-node-domains.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- name: Set public nodes templates
hosts: "{{ hosts | default('monitoring') }}"

tasks:
- name: Generate RPC Nginx config
become: true
ansible.builtin.template:
src: ../../templates/fullnode/nginx-rpc.j2
dest: "/etc/nginx/sites-enabled/rpc"
mode: '0755'

- name: Generate API Nginx config
become: true
ansible.builtin.template:
src: ../../templates/fullnode/nginx-api.j2
dest: "/etc/nginx/sites-enabled/api"
mode: '0755'

- name: Generate Certbot template
become: true
ansible.builtin.shell: "sudo /snap/bin/certbot --nginx --agree-tos -m {{ certbot_email }} -n -d {{ api_domain }},{{ rpc_domain }}"
args:
executable: /bin/bash
register: result
changed_when: false

- name: Verify Nginx config

Check failure on line 28 in playbooks/fullnode/10-public-node-domains.yml

View workflow job for this annotation

GitHub Actions / build

fqcn[action-core]

Use FQCN for builtin module actions (command).
become: yes

Check failure on line 29 in playbooks/fullnode/10-public-node-domains.yml

View workflow job for this annotation

GitHub Actions / build

yaml[truthy]

Truthy value should be one of \[false, true]
command: nginx -t
changed_when: false

- name: (Re)start Nginx
become: true
ansible.builtin.systemd:
state: restarted
name: nginx
14 changes: 14 additions & 0 deletions templates/fullnode/nginx-api.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server {
server_name {{ api_domain }};

location / {
proxy_pass http://127.0.0.1:1317;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}

listen [::]:80;
listen 80;
return 404; # managed by Certbot
}
17 changes: 17 additions & 0 deletions templates/fullnode/nginx-rpc.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
server_name {{ rpc_domain }};

location / {
proxy_pass http://127.0.0.1:26657;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
}

listen [::]:80;
listen 80;
return 404; # managed by Certbot
}

0 comments on commit 362ef59

Please # to comment.