From 4266092707b4d92fad4ebfb5ab0b6dad35998c39 Mon Sep 17 00:00:00 2001 From: ajburnell <30587915+ajburnell@users.noreply.github.com> Date: Sat, 15 Jul 2023 19:19:13 +1000 Subject: [PATCH 1/3] Update default.conf.j2 Part of fix for #795. The nginx_* variables didn't exist. Standardise naming with similar non-packer config: terraform/ansible/roles/nginx_server_post/templates/default.conf.j2 --- packer/ansible/roles/nginx_web_proxy/templates/default.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packer/ansible/roles/nginx_web_proxy/templates/default.conf.j2 b/packer/ansible/roles/nginx_web_proxy/templates/default.conf.j2 index 0a4d38bf..4d6362b3 100644 --- a/packer/ansible/roles/nginx_web_proxy/templates/default.conf.j2 +++ b/packer/ansible/roles/nginx_web_proxy/templates/default.conf.j2 @@ -7,7 +7,7 @@ server { location / { # root /usr/share/nginx/html; # index index.html index.htm; - proxy_pass http://{{nginx_web_proxy_host}}:{{nginx_web_proxy_port}}; + proxy_pass http://{{proxy_server_ip}}:{{proxy_server_port}}; } #error_page 404 /404.html; From b5c14b8d91b23cebb0d5b29e5c043f2bbffd0d7a Mon Sep 17 00:00:00 2001 From: ajburnell <30587915+ajburnell@users.noreply.github.com> Date: Sat, 15 Jul 2023 19:23:50 +1000 Subject: [PATCH 2/3] Update nginx_web_proxy.yml Part of bugfix for #795. From what I can gather, when "packer/ansible/roles/nginx_web_proxy/templates/default.conf.j2" is deployed it doesn't get to see the variables referenced in "terraform/aws/variables.tf" for the packer build. Hence we need to specify them here to prevent the failure. If custom values are set, it will be overridden courtesy of the where clause in terraform/ansible/roles/nginx_server_post/tasks/main.yml anyway. --- packer/ansible/nginx_web_proxy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packer/ansible/nginx_web_proxy.yml b/packer/ansible/nginx_web_proxy.yml index 21c0deae..9f65235d 100644 --- a/packer/ansible/nginx_web_proxy.yml +++ b/packer/ansible/nginx_web_proxy.yml @@ -1,5 +1,8 @@ - hosts: all gather_facts: False become: true + vars: + proxy_server_ip: "10.0.1.12" + proxy_server_port: "8000" roles: - - nginx_web_proxy \ No newline at end of file + - nginx_web_proxy From b3a09dfee27e6e131f1d1c14255da0a98aff7f99 Mon Sep 17 00:00:00 2001 From: ajburnell <30587915+ajburnell@users.noreply.github.com> Date: Sat, 15 Jul 2023 19:25:33 +1000 Subject: [PATCH 3/3] Update main.yml This Ansible task was failing with: "Use 'systemctl start SplunkForwarder' to start the service. Root permission is required. Login as root user or use sudo."]}" This corrects the bug. --- packer/ansible/roles/nginx_web_proxy/tasks/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packer/ansible/roles/nginx_web_proxy/tasks/main.yml b/packer/ansible/roles/nginx_web_proxy/tasks/main.yml index 1cf1599d..16ec157f 100644 --- a/packer/ansible/roles/nginx_web_proxy/tasks/main.yml +++ b/packer/ansible/roles/nginx_web_proxy/tasks/main.yml @@ -7,7 +7,9 @@ - name: restart splunk become: true - command: "/opt/splunkforwarder/bin/splunk restart" + service: + name: SplunkForwarder + state: restarted - name: restart nginx again become: true