mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-13 00:13:09 -06:00
try deferring all startup and registration tasks to handlers; skip if atl_startup_restart is false to match other products
This commit is contained in:
@@ -30,5 +30,8 @@
|
||||
- role: product_common
|
||||
- role: product_install
|
||||
tags: [skip_on_stack_update]
|
||||
# startup before config here so that the handlers from each role are
|
||||
# executed in the right order at the end of the play; only task in startup
|
||||
# is to create the systemd service file, so this should have no ill effects
|
||||
- role: product_startup
|
||||
- role: bitbucket_mesh_config
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
---
|
||||
# Handlers are executed in the order they are defined in the handlers section, not in the order listed in the notify statement.
|
||||
|
||||
- name: Wait for Mesh to become available
|
||||
ansible.builtin.wait_for:
|
||||
port: "{{ mesh_node_port }}"
|
||||
timeout: 300
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
|
||||
- name: Register New Mesh Node
|
||||
ansible.builtin.uri:
|
||||
url: '{{ atl_proxy_name }}/rest/api/latest/admin/git/mesh/nodes'
|
||||
@@ -14,8 +21,6 @@
|
||||
body:
|
||||
name: "{{ mesh_node_name }}"
|
||||
rpcUrl: "{{ mesh_node_scheme }}://{{ mesh_node_name }}.{{ atl_aws_stack_name }}-{{ ansible_ec2_placement_region }}.{{ atl_hostedzone }}:{{ mesh_node_port }}"
|
||||
changed_when: register_mesh_node_result.status == 200
|
||||
notify: Stop Product
|
||||
register: register_mesh_node_result
|
||||
until: register_mesh_node_result is not failed
|
||||
retries: 5
|
||||
@@ -43,15 +48,6 @@
|
||||
delay: 30
|
||||
no_log: True
|
||||
|
||||
- name: Stop Product
|
||||
ansible.builtin.service:
|
||||
name: "{{ atl_systemd_service_name }}"
|
||||
state: stopped
|
||||
when:
|
||||
- not atl_startup_restart | bool
|
||||
- molecule_yml is not defined
|
||||
no_log: true
|
||||
|
||||
- name: Remove orphan_vol lease lock
|
||||
ansible.builtin.file:
|
||||
path: '{{ atl_shared_mountpoint }}/.{{ orphan_vol }}'
|
||||
|
||||
@@ -1,32 +1,4 @@
|
||||
---
|
||||
- name: Enable and Start Mesh Product
|
||||
ansible.builtin.service:
|
||||
name: "{{ atl_systemd_service_name }}"
|
||||
enabled: true
|
||||
state: started
|
||||
when:
|
||||
- molecule_yml is not defined
|
||||
no_log: true
|
||||
|
||||
- name: Wait for service to become available
|
||||
ansible.builtin.wait_for:
|
||||
port: "{{ mesh_node_port }}"
|
||||
timeout: 300
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
|
||||
- name: Trigger the handler to update this existing mesh node
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||
changed_when: true
|
||||
notify: Update Existing Mesh Node
|
||||
when:
|
||||
- bitbucket_cluster_available
|
||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||
- (mesh_node_id is defined) and (mesh_node_id | length > 0)
|
||||
vars:
|
||||
query: "[?name=='{{ mesh_node_name }}']"
|
||||
|
||||
# if node.id doesnt exist this is new/clean mesh node and we need to register a new node
|
||||
- name: If this node is not registered, cleanup any old keys to allow registration of new
|
||||
@@ -43,13 +15,36 @@
|
||||
vars:
|
||||
query: "[?name=='{{ mesh_node_name }}']"
|
||||
|
||||
- name: Trigger the handler to update this existing mesh node
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||
changed_when: true
|
||||
notify:
|
||||
- Enable Product
|
||||
- Restart Product
|
||||
- Wait for Mesh to become available
|
||||
- Update Existing Mesh Node
|
||||
when:
|
||||
- atl_startup_restart | bool
|
||||
- bitbucket_cluster_available
|
||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||
- (mesh_node_id is defined) and (mesh_node_id | length > 0)
|
||||
vars:
|
||||
query: "[?name=='{{ mesh_node_name }}']"
|
||||
|
||||
- name: Trigger the handler to register this new mesh node
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||
changed_when: true
|
||||
notify: Register New Mesh Node
|
||||
notify:
|
||||
- Enable Product
|
||||
- Restart Product
|
||||
- Wait for Mesh to become available
|
||||
- Register New Mesh Node
|
||||
when:
|
||||
- atl_startup_restart | bool
|
||||
- bitbucket_cluster_available
|
||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||
- (mesh_node_id is not defined) or (mesh_node_id | length == 0)
|
||||
|
||||
Reference in New Issue
Block a user