diff --git a/deploy/deploy.yml b/deploy/deploy.yml index 5b525fc1ea0ce523368505508589f726a20e735c..994487bb45b2bbae9a656abd831a76153b5742c6 100644 --- a/deploy/deploy.yml +++ b/deploy/deploy.yml @@ -2,20 +2,22 @@ - name: StationControl Early Deployment hosts: all vars: - default_install_path: ~/git/tango + base_station_config: "LOFAR_ConfigDb.json" + install_path: ~/git/tango + databaseds_port: 10000 tasks: - - name: Register make installation status - command: which make - changed_when: false - failed_when: make_installed.rc not in [0,1] - register: make_installed - - name: Register git installation status - command: which git - changed_when: false - failed_when: git_installed.rc not in [0,1] - register: git_installed + - name: Check make installed + include_tasks: + file: tasks/check_binary_install.yml + vars: + program: make + - name: Check git installed + include_tasks: + file: tasks/check_binary_install.yml + vars: + program: git - name: Register tango directory status - shell: cd {{ default_install_path }} + shell: cd {{ install_path }} args: chdir: ~ changed_when: false @@ -31,19 +33,13 @@ fi exit 0 args: - chdir: "{{ default_install_path }}" + chdir: "{{ install_path }}" changed_when: false failed_when: pending_changes.rc not in [0,1] register: pending_changes +# Several issues with this variable being unset in ansible 2.2 +# where encountered, keep debug in case needed - debug: var=pending_changes - - name: Check make installation status - fail: - msg: "Make does not appear to be installed!" - when: make_installed.rc not in [0] - - name: Check git installation status - fail: - msg: "Git does not appear to be installed!" - when: git_installed.rc not in [0] - name: Check tango directory status fail: msg: "Tango directory appears to be missing!" @@ -56,66 +52,62 @@ changed_when: false shell: "make stop" args: - chdir: "{{ default_install_path }}/docker-compose" + chdir: "{{ install_path }}/docker-compose" # - name: Git Fetch All # changed_when: false # shell: "git fetch --all" # args: -# chdir: "{{ default_install_path }}" +# chdir: "{{ install_path }}" - name: Update Sources changed_when: false shell: "git checkout {{ station_version }}" args: - chdir: "{{ default_install_path }}" + chdir: "{{ install_path }}" - name: Pull Images changed_when: false shell: "make pull" args: - chdir: "{{ default_install_path }}/docker-compose" + chdir: "{{ install_path }}/docker-compose" - name: Build Images changed_when: false shell: "make build" args: - chdir: "{{ default_install_path }}/docker-compose" + chdir: "{{ install_path }}/docker-compose" - name: Start Database changed_when: false shell: "make minimal" args: - chdir: "{{ default_install_path }}/docker-compose" + chdir: "{{ install_path }}/docker-compose" - name: Wait for databaseds ansible.builtin.wait_for: - port: 10000 + port: "{{ databaseds_port }}" delay: 10 - name: Update Base Database Config - changed_when: false - shell: "./sbin/load_ConfigDb.sh CDB/LOFAR_ConfigDb.json" - args: - chdir: "{{ default_install_path }}" - - name: Get Base Database Config - changed_when: false - shell: "./sbin/load_ConfigDb.sh CDB/LOFAR_ConfigDb.json 2>&1" - register: base_dsconfig_result - args: - chdir: "{{ default_install_path }}" + include_tasks: + file: tasks/update_database_config.yml + vars: + database_config: "{{ base_station_config }}" + base_path: "{{ install_path }}" - name: Verify Base Database Config - when: '"No changes needed" in base_dsconfig_result.stdout' - debug: msg="Base database changes stored" + include_tasks: + file: tasks/verify_database_config.yml + vars: + database_config: "{{ base_station_config }}" + base_path: "{{ install_path }}" - name: Update Station Database Config - changed_when: false - shell: "./sbin/load_ConfigDb.sh CDB/stations/{{ station_config }}" - args: - chdir: "{{ default_install_path }}" - - name: Get Station Database Config - changed_when: false - shell: "./sbin/load_ConfigDb.sh CDB/stations/{{ station_config }} 2>&1" - register: station_dsconfig_result - args: - chdir: "{{ default_install_path }}" + include_tasks: + file: tasks/update_database_config.yml + vars: + database_config: "stations/{{ station_config }}" + base_path: "{{ install_path }}" - name: Verify Station Database Config - when: '"No changes needed" in station_dsconfig_result.stdout' - debug: msg="Station database changes stored" + include_tasks: + file: tasks/verify_database_config.yml + vars: + database_config: "stations/{{ station_config }}" + base_path: "{{ install_path }}" - name: Start Station changed_when: false shell: "make start" args: - chdir: "{{ default_install_path }}/docker-compose" + chdir: "{{ install_path }}/docker-compose" diff --git a/deploy/tasks/check_binary_install.yml b/deploy/tasks/check_binary_install.yml new file mode 100644 index 0000000000000000000000000000000000000000..f114fd87e7b7bd25d7f6b848b25c32aa9324efa2 --- /dev/null +++ b/deploy/tasks/check_binary_install.yml @@ -0,0 +1,9 @@ + - name: Register installation status + command: which {{ program }} + changed_when: false + failed_when: installed.rc not in [0,1] + register: installed + - name: Check installation status + fail: + msg: "{{ program }} does not appear to be installed!" + when: installed.rc not in [0] \ No newline at end of file diff --git a/deploy/tasks/update_database_config.yml b/deploy/tasks/update_database_config.yml new file mode 100644 index 0000000000000000000000000000000000000000..be321c5769d48a6443de18340033c8cdaffd661f --- /dev/null +++ b/deploy/tasks/update_database_config.yml @@ -0,0 +1,5 @@ + - name: Update Database Config + changed_when: false + shell: "./sbin/load_ConfigDb.sh CDB/{{ database_config }}" + args: + chdir: "{{ base_path }}" \ No newline at end of file diff --git a/deploy/tasks/verify_database_config.yml b/deploy/tasks/verify_database_config.yml new file mode 100644 index 0000000000000000000000000000000000000000..1df3681e4eae0fe7d04cede8f5cd3820aa6cbd67 --- /dev/null +++ b/deploy/tasks/verify_database_config.yml @@ -0,0 +1,9 @@ + - name: Get Database Config + changed_when: false + shell: "./sbin/load_ConfigDb.sh CDB/{{ database_config }} 2>&1" + register: dsconfig_result + args: + chdir: "{{ base_path }}" + - name: Verify Database Config + when: '"No changes needed" in dsconfig_result.stdout' + debug: msg="Database changes stored" \ No newline at end of file