Skip to content
Snippets Groups Projects
Commit edb7aeda authored by Corné Lukken's avatar Corné Lukken
Browse files

L2SS-983: Templates tasks for ansible deploy

parent d5729b6d
No related branches found
No related tags found
1 merge request!469L2SS-983: Deployment through environments and ansible
...@@ -2,20 +2,22 @@ ...@@ -2,20 +2,22 @@
- name: StationControl Early Deployment - name: StationControl Early Deployment
hosts: all hosts: all
vars: vars:
default_install_path: ~/git/tango base_station_config: "LOFAR_ConfigDb.json"
install_path: ~/git/tango
databaseds_port: 10000
tasks: tasks:
- name: Register make installation status - name: Check make installed
command: which make include_tasks:
changed_when: false file: tasks/check_binary_install.yml
failed_when: make_installed.rc not in [0,1] vars:
register: make_installed program: make
- name: Register git installation status - name: Check git installed
command: which git include_tasks:
changed_when: false file: tasks/check_binary_install.yml
failed_when: git_installed.rc not in [0,1] vars:
register: git_installed program: git
- name: Register tango directory status - name: Register tango directory status
shell: cd {{ default_install_path }} shell: cd {{ install_path }}
args: args:
chdir: ~ chdir: ~
changed_when: false changed_when: false
...@@ -31,19 +33,13 @@ ...@@ -31,19 +33,13 @@
fi fi
exit 0 exit 0
args: args:
chdir: "{{ default_install_path }}" chdir: "{{ install_path }}"
changed_when: false changed_when: false
failed_when: pending_changes.rc not in [0,1] failed_when: pending_changes.rc not in [0,1]
register: pending_changes 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 - 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 - name: Check tango directory status
fail: fail:
msg: "Tango directory appears to be missing!" msg: "Tango directory appears to be missing!"
...@@ -56,66 +52,62 @@ ...@@ -56,66 +52,62 @@
changed_when: false changed_when: false
shell: "make stop" shell: "make stop"
args: args:
chdir: "{{ default_install_path }}/docker-compose" chdir: "{{ install_path }}/docker-compose"
# - name: Git Fetch All # - name: Git Fetch All
# changed_when: false # changed_when: false
# shell: "git fetch --all" # shell: "git fetch --all"
# args: # args:
# chdir: "{{ default_install_path }}" # chdir: "{{ install_path }}"
- name: Update Sources - name: Update Sources
changed_when: false changed_when: false
shell: "git checkout {{ station_version }}" shell: "git checkout {{ station_version }}"
args: args:
chdir: "{{ default_install_path }}" chdir: "{{ install_path }}"
- name: Pull Images - name: Pull Images
changed_when: false changed_when: false
shell: "make pull" shell: "make pull"
args: args:
chdir: "{{ default_install_path }}/docker-compose" chdir: "{{ install_path }}/docker-compose"
- name: Build Images - name: Build Images
changed_when: false changed_when: false
shell: "make build" shell: "make build"
args: args:
chdir: "{{ default_install_path }}/docker-compose" chdir: "{{ install_path }}/docker-compose"
- name: Start Database - name: Start Database
changed_when: false changed_when: false
shell: "make minimal" shell: "make minimal"
args: args:
chdir: "{{ default_install_path }}/docker-compose" chdir: "{{ install_path }}/docker-compose"
- name: Wait for databaseds - name: Wait for databaseds
ansible.builtin.wait_for: ansible.builtin.wait_for:
port: 10000 port: "{{ databaseds_port }}"
delay: 10 delay: 10
- name: Update Base Database Config - name: Update Base Database Config
changed_when: false include_tasks:
shell: "./sbin/load_ConfigDb.sh CDB/LOFAR_ConfigDb.json" file: tasks/update_database_config.yml
args: vars:
chdir: "{{ default_install_path }}" database_config: "{{ base_station_config }}"
- name: Get Base Database Config base_path: "{{ install_path }}"
changed_when: false
shell: "./sbin/load_ConfigDb.sh CDB/LOFAR_ConfigDb.json 2>&1"
register: base_dsconfig_result
args:
chdir: "{{ default_install_path }}"
- name: Verify Base Database Config - name: Verify Base Database Config
when: '"No changes needed" in base_dsconfig_result.stdout' include_tasks:
debug: msg="Base database changes stored" file: tasks/verify_database_config.yml
vars:
database_config: "{{ base_station_config }}"
base_path: "{{ install_path }}"
- name: Update Station Database Config - name: Update Station Database Config
changed_when: false include_tasks:
shell: "./sbin/load_ConfigDb.sh CDB/stations/{{ station_config }}" file: tasks/update_database_config.yml
args: vars:
chdir: "{{ default_install_path }}" database_config: "stations/{{ station_config }}"
- name: Get Station Database Config base_path: "{{ install_path }}"
changed_when: false
shell: "./sbin/load_ConfigDb.sh CDB/stations/{{ station_config }} 2>&1"
register: station_dsconfig_result
args:
chdir: "{{ default_install_path }}"
- name: Verify Station Database Config - name: Verify Station Database Config
when: '"No changes needed" in station_dsconfig_result.stdout' include_tasks:
debug: msg="Station database changes stored" file: tasks/verify_database_config.yml
vars:
database_config: "stations/{{ station_config }}"
base_path: "{{ install_path }}"
- name: Start Station - name: Start Station
changed_when: false changed_when: false
shell: "make start" shell: "make start"
args: args:
chdir: "{{ default_install_path }}/docker-compose" chdir: "{{ install_path }}/docker-compose"
- 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
- 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
- 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment