From c12aa3459de17257c42243401b91ecf721f7100e Mon Sep 17 00:00:00 2001 From: Expand-sys Date: Wed, 21 Jun 2023 17:18:55 +1000 Subject: [PATCH] fixed some edge cases --- inventory | 2 +- main.ansible.yml | 36 ++++++++++++++++++------------------ vars/default.yml | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/inventory b/inventory index 949fe01..0ed1766 100644 --- a/inventory +++ b/inventory @@ -1,2 +1,2 @@ [all] -54.38.56.147 ansible_ssh_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no' \ No newline at end of file +127.0.0.1 ansible_ssh_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no' \ No newline at end of file diff --git a/main.ansible.yml b/main.ansible.yml index 4ed0e03..aab7cb4 100644 --- a/main.ansible.yml +++ b/main.ansible.yml @@ -11,11 +11,6 @@ tasks: - - name: Refresh packages update - ansible.builtin.yum: - name: "*" - update_cache: true - - name: Add repository ansible.builtin.yum: name: epel-release @@ -127,7 +122,7 @@ ansible.builtin.command: chdir: '{{ BUILD_DIR }}/CCash/build' cmd: './bank {{ ADMIN_A }} {{ SAVE_FREQ }} true' - when: START_SERVICES = true + when: START_SERVICES == true - name: Clone Web ansible.builtin.git: @@ -135,37 +130,37 @@ dest: '{{ BUILD_DIR }}/CCash/web' update: true force: true - when: WEB_ENABLED = true + when: WEB_ENABLED == true - name: "Install Nodejs 18 module" ansible.builtin.command: dnf module install -y nodejs:18/common register: result changed_when: - '"Enabling module streams" in result.stdout' - when: ansible_os_family = "RedHat" and WEB_ENABLED = true + when: ansible_os_family == "RedHat" and WEB_ENABLED == true - name: Install pm2 community.general.npm: path: '{{ BUILD_DIR }}/CCash/web' name: pm2 global: true - when: WEB_ENABLED = true + when: WEB_ENABLED == true - name: Install web dependencies community.general.npm: path: '{{ BUILD_DIR }}/CCash/web' - when: WEB_ENABLED = true + when: WEB_ENABLED == true - name: Create .env file ansible.builtin.copy: content: | - BANKAPIURL={{ ansible_facts["all_ipv4_addresses"][0] }} + BANKAPIURL=http://127.0.0.1:{{ CCASH_PORT }} SECURE=true SETUP=true PORT={{ WEB_PORT }} dest: '{{ BUILD_DIR }}/CCash/web/.env' mode: 0700 - when: WEB_ENABLED = true + when: WEB_ENABLED == true - name: Create pm2 file ansible.builtin.copy: @@ -178,7 +173,7 @@ } dest: "{{ BUILD_DIR }}/CCash/web/pm2.json" mode: 0700 - when: WEB_ENABLED = true + when: WEB_ENABLED == true - name: Start webapp service @@ -186,14 +181,14 @@ chdir: "{{ BUILD_DIR }}/CCash/web" cmd: | pm2 start index.js --update-env --name 'CCashFrontend' -f - when: START_SERVICES = true and WEB_ENABLED = true + when: START_SERVICES == true and WEB_ENABLED == true - name: Enable web app on boot ansible.builtin.command: chdir: "{{ BUILD_DIR }}/CCash/web" cmd: | pm2 startup - when: START_ON_BOOT = true and START_SERVICES = true and WEB_ENABLED = true + when: START_ON_BOOT == true and START_SERVICES == true and WEB_ENABLED == true - name: Enable ccash on boot ansible.builtin.cron: @@ -201,12 +196,17 @@ special_time: reboot state: present job: '{{ BUILD_DIR }}/CCash/build/bank {{ ADMIN_A }} {{ SAVE_FREQ }} true' - when: START_ON_BOOT = true + when: START_ON_BOOT == true - name: Allow firewalld ports ansible.posix.firewalld: permanent: true - port: 443/tcp + port: '{{ CCASH_PORT }}/tcp' + state: enabled + - name: Allow firewalld ports + ansible.posix.firewalld: + permanent: true + port: '{{ CCASH_PORT_S }}/tcp' state: enabled - name: Allow firewalld ports @@ -214,4 +214,4 @@ permanent: true port: 3000/tcp state: enabled - when: WEB_ENABLED = true + when: WEB_ENABLED == true diff --git a/vars/default.yml b/vars/default.yml index eb40273..0508952 100644 --- a/vars/default.yml +++ b/vars/default.yml @@ -3,10 +3,10 @@ BUILD_DIR: "/root" ADMIN_A: "admin" SAVE_FREQ: "2" USE_DEPRECATED_ENDPOINTS: "true" -WEB_ENABLED: false +WEB_ENABLED: true WEB_PORT: "3000" CCASH_PORT: 8080 CCASH_PORT_S: 8443 -START_SERVICES: false +START_SERVICES: true START_ON_BOOT: true BRANCH: "main" \ No newline at end of file