mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-15 09:23:06 -06:00
task name, comments, and other general formatting updates
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
- molecule_yml is not defined
|
- molecule_yml is not defined
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
- name: register_mesh_node
|
- name: Register Mesh Node
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: '{{ atl_proxy_name }}/rest/api/latest/admin/git/mesh/nodes'
|
url: '{{ atl_proxy_name }}/rest/api/latest/admin/git/mesh/nodes'
|
||||||
method: POST
|
method: POST
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
delay: 30
|
delay: 30
|
||||||
no_log: True
|
no_log: True
|
||||||
|
|
||||||
- name: update_mesh_node
|
- name: Update Mesh Node
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: '{{ atl_proxy_name }}/rest/api/latest/admin/git/mesh/nodes/{{ mesh_node_id }}'
|
url: '{{ atl_proxy_name }}/rest/api/latest/admin/git/mesh/nodes/{{ mesh_node_id }}'
|
||||||
method: PUT
|
method: PUT
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
delay: 30
|
delay: 30
|
||||||
no_log: True
|
no_log: True
|
||||||
|
|
||||||
- name: Remove orphan_vol lease_lock
|
- name: Remove orphan_vol lease lock
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: '{{ atl_shared_mountpoint }}/.{{ orphan_vol }}'
|
path: '{{ atl_shared_mountpoint }}/.{{ orphan_vol }}'
|
||||||
state: absent
|
state: absent
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
# handle setting up to call the bitbucket api
|
# handle setting up to call the bitbucket api
|
||||||
|
|
||||||
- name: retrieve cloudformation facts
|
- name: Retrieve cloudformation facts
|
||||||
amazon.aws.cloudformation_info:
|
amazon.aws.cloudformation_info:
|
||||||
stack_name: '{{ atl_aws_stack_id }}'
|
stack_name: '{{ atl_aws_stack_id }}'
|
||||||
region: '{{ ansible_ec2_placement_region }}'
|
region: '{{ ansible_ec2_placement_region }}'
|
||||||
stack_resources: yes
|
stack_resources: yes
|
||||||
register: cfn_stack_facts
|
register: cfn_stack_facts
|
||||||
|
|
||||||
- name: set fact for the MeshRegistrationCredentialsSecret
|
- name: Set fact for the MeshRegistrationCredentialsSecret
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_registration_credential_secret: "{{ cfn_stack_facts.cloudformation[atl_aws_stack_name].stack_resources.MeshRegistrationCredentialsSecret }}"
|
mesh_registration_credential_secret: "{{ cfn_stack_facts.cloudformation[atl_aws_stack_name].stack_resources.MeshRegistrationCredentialsSecret }}"
|
||||||
# NOTE: we decided we want to barf early if the secret doesnt exist as ll the rest of this is somewhat useless if we cant register nodes
|
# NOTE: we decided we want to barf early if the secret doesnt exist as ll the rest of this is somewhat useless if we cant register nodes
|
||||||
# when:
|
# when:
|
||||||
# - cfn_stack_facts.cloudformation[stack_name].stack_resources.MeshRegistrationCredentialsSecret is defined
|
# - cfn_stack_facts.cloudformation[stack_name].stack_resources.MeshRegistrationCredentialsSecret is defined
|
||||||
|
|
||||||
- name: get the mesh registration username
|
- name: Retrieve the mesh registration username
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_registration_username: "{{ lookup('amazon.aws.secretsmanager_secret', secretpath, region=ansible_ec2_placement_region, bypath=false, nested=true) }}"
|
mesh_registration_username: "{{ lookup('amazon.aws.secretsmanager_secret', secretpath, region=ansible_ec2_placement_region, bypath=false, nested=true) }}"
|
||||||
ignore_errors: no
|
ignore_errors: no
|
||||||
vars:
|
vars:
|
||||||
secretpath: "{{ mesh_registration_credential_secret }}.username"
|
secretpath: "{{ mesh_registration_credential_secret }}.username"
|
||||||
|
|
||||||
- name: get the mesh registration password
|
- name: Retrieve the mesh registration password
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_registration_password: "{{ lookup('amazon.aws.secretsmanager_secret', secretpath, region=ansible_ec2_placement_region, bypath=false, nested=true) }}"
|
mesh_registration_password: "{{ lookup('amazon.aws.secretsmanager_secret', secretpath, region=ansible_ec2_placement_region, bypath=false, nested=true) }}"
|
||||||
ignore_errors: no
|
ignore_errors: no
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
secretpath: "{{ mesh_registration_credential_secret }}.password"
|
secretpath: "{{ mesh_registration_credential_secret }}.password"
|
||||||
no_log: True
|
no_log: True
|
||||||
|
|
||||||
- name: generate the basic auth string
|
- name: Generate the basic auth string
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_basic_auth: "{{ auth_string | b64encode }}"
|
mesh_basic_auth: "{{ auth_string | b64encode }}"
|
||||||
vars:
|
vars:
|
||||||
|
|||||||
@@ -10,25 +10,25 @@
|
|||||||
|
|
||||||
# assume bbdc secret exists (else fail) - setup stuff for calling bitbucket rest api and get mesh node report
|
# assume bbdc secret exists (else fail) - setup stuff for calling bitbucket rest api and get mesh node report
|
||||||
# get the registered mesh node info as we need it for determining nodenames
|
# get the registered mesh node info as we need it for determining nodenames
|
||||||
- name: Import bitbucket api setup pieces and do initial mesh node_report
|
- name: Import Bitbucket API setup pieces
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: bitbucket_api_setup.yml
|
file: bitbucket_api_setup.yml
|
||||||
|
|
||||||
- name: import/run mesh_node_report
|
- name: Import and run mesh_node_report
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: mesh_node_report.yml
|
file: mesh_node_report.yml
|
||||||
|
|
||||||
- name: set fact if this stack is a mesh clone
|
- name: Set fact if this stack is a mesh clone
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_clone: "{{ (atl_mesh_snapshot_az1 is defined) | ternary(true, false) }}"
|
mesh_clone: "{{ (atl_mesh_snapshot_az1 is defined) | ternary(true, false) }}"
|
||||||
|
|
||||||
# workout if there is a valid mesh_vol, either mounted or abandoned, set mesh_vol or mesh_snap
|
# workout if there is a valid mesh_vol, either mounted or abandoned, set mesh_vol or mesh_snap
|
||||||
- name: check for valid mesh_vol
|
- name: Check for valid mesh_vol
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: meshvol_check.yml
|
file: meshvol_check.yml
|
||||||
|
|
||||||
# create/set mesh_vol if still needed
|
# create/set mesh_vol if still needed
|
||||||
- name: create/set mesh_vol if still needed
|
- name: Create/set mesh_vol if still needed
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: meshvol_create.yml
|
file: meshvol_create.yml
|
||||||
when:
|
when:
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
# ensure logs and cache have fs and are mounted
|
# ensure logs and cache have fs and are mounted
|
||||||
# action this block when mesh volume is not in mount list
|
# action this block when mesh volume is not in mount list
|
||||||
- name: setup and mount mesh releated filesystems
|
- name: Setup and mount mesh releated filesystems
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: meshvols_setup.yml
|
file: meshvols_setup.yml
|
||||||
when:
|
when:
|
||||||
@@ -44,26 +44,26 @@
|
|||||||
- "'/dev/xvdd' not in devices_list"
|
- "'/dev/xvdd' not in devices_list"
|
||||||
|
|
||||||
# Setup Mesh product
|
# Setup Mesh product
|
||||||
- name: setup mesh product and related pieces
|
- name: Setup mesh product and related pieces
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: mesh_setup.yml
|
file: mesh_setup.yml
|
||||||
|
|
||||||
# get tag info of mesh_vol
|
# get tag info of mesh_vol
|
||||||
- name: get info of attached mesh_vol
|
- name: Retrieve info of attached mesh_vol
|
||||||
amazon.aws.ec2_vol_info:
|
amazon.aws.ec2_vol_info:
|
||||||
region: "{{ ansible_ec2_placement_region }}"
|
region: "{{ ansible_ec2_placement_region }}"
|
||||||
filters:
|
filters:
|
||||||
volume-id: "{{ mesh_vol }}"
|
volume-id: "{{ mesh_vol }}"
|
||||||
register: mesh_vol_tag_info
|
register: mesh_vol_info
|
||||||
tags: notest # doesn't work in molecule
|
tags: notest # doesn't work in molecule
|
||||||
|
|
||||||
- name: set mesh_node_name_tag var from the mesh_node_name tag of .mesh_vol
|
- name: Set mesh_node_name_tag var from the mesh_node_name tag of mesh_vol
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_node_name: "{{ mesh_vol_tag_info.volumes[0].tags['mesh_node_name'] }}"
|
mesh_node_name: "{{ mesh_vol_info.volumes[0].tags['mesh_node_name'] }}"
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
# workout if we are a clone_firstrun
|
# workout if we are a clone_firstrun
|
||||||
- name: remove node_id from mesh.properties if new_meshvol_from_snap
|
- name: Remove node.id from mesh.properties if mesh volume was re-hydrated from snapshot
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ mesh_properties_file }}"
|
path: "{{ mesh_properties_file }}"
|
||||||
regexp: '^node\.id.+$'
|
regexp: '^node\.id.+$'
|
||||||
@@ -72,41 +72,41 @@
|
|||||||
- new_meshvol_from_snap is defined
|
- new_meshvol_from_snap is defined
|
||||||
- new_meshvol_from_snap | bool
|
- new_meshvol_from_snap | bool
|
||||||
|
|
||||||
- name: set mesh_node_id var from the existing mesh.properties file
|
- name: Set mesh_node_id var from the existing mesh.properties file
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_node_id: "{{ lookup('ansible.builtin.ini', 'node.id type=properties file={{ mesh_properties_file }}', errors='ignore' )| default('absent', true) }}"
|
mesh_node_id: "{{ lookup('ansible.builtin.ini', 'node.id type=properties file={{ mesh_properties_file }}', errors='ignore') | default('absent', true) }}"
|
||||||
|
|
||||||
- name: set string to test mesh_clone_firstrun (node_name contains meshnode_{{ mesh_node_id }}")
|
- name: Set string to test mesh_clone_firstrun (node_name contains meshnode_{{ mesh_node_id }}")
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_clone_teststring: "meshnode_{{ mesh_node_id }}"
|
mesh_clone_teststring: "meshnode_{{ mesh_node_id }}"
|
||||||
|
|
||||||
# workout if this is mesh_clone_firstrun - either no mounted volume or teststring found in mesh_nodes_report
|
# workout if this is mesh_clone_firstrun
|
||||||
- name: work out if this is firstrun of a mesh_clone
|
- name: Work out if this is first_run of a mesh_clone
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_clone_firstrun: false
|
mesh_clone_firstrun: false
|
||||||
|
|
||||||
- name: set firstrun true if mesh_node_id is absent
|
- name: Set firstrun true if mesh_node_id is absent
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_clone_firstrun: true
|
mesh_clone_firstrun: true
|
||||||
when: mesh_node_id == 'absent'
|
when: mesh_node_id == 'absent'
|
||||||
|
|
||||||
# if meshvol has no petname or this is the first run of a clone, create a new petname, tag the vol and set mesh_node_name
|
# if meshvol has no petname or this is the first run of a clone, create a new petname, tag the vol and set mesh_node_name
|
||||||
- name: new petname related processing
|
- name: New petname related processing
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: mesh_newpet.yml
|
file: mesh_newpet.yml
|
||||||
when: (mesh_node_name is not defined) or (mesh_node_name | length == 0) or mesh_clone_firstrun
|
when: (mesh_node_name is not defined) or (mesh_node_name | length == 0) or mesh_clone_firstrun
|
||||||
|
|
||||||
# bundle all the node_name releated updates together
|
# bundle all the node_name releated updates together
|
||||||
- name: mesh_node_name related processing
|
- name: Process mesh_node_name related tasks
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: mesh_node_name.yml
|
file: mesh_node_name.yml
|
||||||
|
|
||||||
# handle reregistering the correct node if node.id exists
|
# handle reregistering the correct node if node.id exists
|
||||||
- name: set mesh_node_id var from the existing mesh.properties file
|
- name: Set mesh_node_id var from the existing mesh.properties file
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_node_id: "{{ lookup('ansible.builtin.ini', 'node.id type=properties file={{ mesh_properties_file }}') | split('.') | first }}"
|
mesh_node_id: "{{ lookup('ansible.builtin.ini', 'node.id type=properties file={{ mesh_properties_file }}') | split('.') | first }}"
|
||||||
|
|
||||||
# handle functionality relating to starting and registering the mesh service
|
# handle functionality relating to starting and registering the mesh service
|
||||||
- name: mesh service related processing
|
- name: Mesh service related processing
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.import_tasks:
|
||||||
file: mesh_service.yml
|
file: mesh_service.yml
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
# this may need to be expanded later, but don't add node.id unless you get it from bitbucket primary cluster
|
# this may need to be expanded later, but don't add node.id unless you get it from bitbucket primary cluster
|
||||||
# first see if it's already set - if it is, use that, else generate a random one
|
# first see if it's already set - if it is, use that, else generate a random one
|
||||||
|
|
||||||
- name: set mesh_node_name var from the existing mesh.properties file
|
- name: Set mesh_node_name var from the existing mesh.properties file
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_node_name: "{{ lookup('ansible.builtin.ini', 'node.name type=properties file={{ mesh_properties_file }}') | split('.') | first }}"
|
mesh_node_name: "{{ lookup('ansible.builtin.ini', 'node.name type=properties file={{ mesh_properties_file }}') | split('.') | first }}"
|
||||||
|
|
||||||
- name: generate a pet name if mesh_node_name is empty or this is a clone firstrun # noqa jinja[invalid]
|
- name: Generate a pet name if mesh_node_name is empty or this is a clone firstrun # noqa jinja[invalid]
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_node_name: "{{ lookup('community.general.random_pet', words=3) }}"
|
mesh_node_name: "{{ lookup('community.general.random_pet', words=3) }}"
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
---
|
---
|
||||||
# update mesh.properties with the mesh_node_name from the tag in mesh_vol_info
|
# update mesh.properties with the mesh_node_name from the tag in mesh_vol_info
|
||||||
- name: enforce node.name per volume tag
|
- name: Update mesh.properties 'node.name' with mesh_node_name value
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
line: node.name={{ mesh_node_name }}
|
line: node.name={{ mesh_node_name }}
|
||||||
path: "{{ mesh_properties_file }}"
|
path: "{{ mesh_properties_file }}"
|
||||||
regexp: '^node\.name='
|
regexp: '^node\.name='
|
||||||
|
|
||||||
- name: enforce node.rpc-url per node_name
|
- name: Update mesh.properties 'node.rpc-url' with mesh_node_name value
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ mesh_properties_file }}"
|
path: "{{ mesh_properties_file }}"
|
||||||
search_string: 'node.rpc-url='
|
search_string: 'node.rpc-url='
|
||||||
line: node.rpc-url={{ mesh_node_scheme }}://{{ mesh_node_name }}.{{ atl_aws_stack_name }}-{{ ansible_ec2_placement_region }}.{{ atl_hostedzone }}:{{ mesh_node_port }}
|
line: node.rpc-url={{ mesh_node_scheme }}://{{ mesh_node_name }}.{{ atl_aws_stack_name }}-{{ ansible_ec2_placement_region }}.{{ atl_hostedzone }}:{{ mesh_node_port }}
|
||||||
|
|
||||||
- name: enforce metrics.tags.host per volume tag
|
- name: Update mesh.properties 'metrics.tags.host' with mesh_node_name value
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ mesh_properties_file }}"
|
path: "{{ mesh_properties_file }}"
|
||||||
search_string: 'metrics.tags.host='
|
search_string: 'metrics.tags.host='
|
||||||
line: metrics.tags.host={{ mesh_node_name }}
|
line: metrics.tags.host={{ mesh_node_name }}
|
||||||
|
|
||||||
# the idea here is that the pet name will persist through clones, and just the stack_name - region part of the url will change (and maybe the hosted zone)
|
# the idea here is that the pet name will persist through clones, and just the stack_name - region part of the url will change (and maybe the hosted zone)
|
||||||
- name: create r53 entry for this mesh node based on the mesh_node_name
|
- name: Create Route 53 entry for this mesh node based on the mesh_node_name
|
||||||
amazon.aws.route53:
|
amazon.aws.route53:
|
||||||
command: create
|
command: create
|
||||||
zone: "{{ atl_hostedzone }}"
|
zone: "{{ atl_hostedzone }}"
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
- mesh_vol is regex('^vol-.*')
|
- mesh_vol is regex('^vol-.*')
|
||||||
tags: notest # doesn't work in molecule
|
tags: notest # doesn't work in molecule
|
||||||
|
|
||||||
- name: build a dict of tags from the ec2 instance to apply to the ebs volume
|
- name: Build a dict of tags from the EC2 instance to apply to the EBS volume
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ebs_tags: "{{ ebs_tags | default({}) | combine({item.key: item.value}) }}"
|
ebs_tags: "{{ ebs_tags | default({}) | combine({item.key: item.value}) }}"
|
||||||
when:
|
when:
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
- item.key is not match("aws:.*")
|
- item.key is not match("aws:.*")
|
||||||
with_dict: "{{ ec2_instance_tags.tags }}"
|
with_dict: "{{ ec2_instance_tags.tags }}"
|
||||||
|
|
||||||
- name: apply the tags from the ec2 instance to the ebs volume
|
- name: Apply the tags from the EC2 instance to the EBS volume
|
||||||
amazon.aws.ec2_tag:
|
amazon.aws.ec2_tag:
|
||||||
region: "{{ ansible_ec2_placement_region }}"
|
region: "{{ ansible_ec2_placement_region }}"
|
||||||
resource: "{{ ((mesh_vol is defined) and (mesh_vol | length > 0)) | ternary(mesh_vol, mesh_vol_info.volume.id) }}"
|
resource: "{{ ((mesh_vol is defined) and (mesh_vol | length > 0)) | ternary(mesh_vol, mesh_vol_info.volume.id) }}"
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
purge_tags: false
|
purge_tags: false
|
||||||
tags: notest # doesn't work in molecule
|
tags: notest # doesn't work in molecule
|
||||||
|
|
||||||
- name: add the mesh_node_name tag to the ebs volume and current ec2
|
- name: Add the mesh_node_name tag to the EBS volume and current EC2
|
||||||
amazon.aws.ec2_tag:
|
amazon.aws.ec2_tag:
|
||||||
region: "{{ ansible_ec2_placement_region }}"
|
region: "{{ ansible_ec2_placement_region }}"
|
||||||
resource: "{{ item }}"
|
resource: "{{ item }}"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# create a report on existing mesh nodes
|
# create a report on existing mesh nodes
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: try calling the server to get a list of the mesh nodes
|
- name: Try calling the server to get a list of the mesh nodes
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: '{{ atl_proxy_name }}/rest/api/latest/admin/git/mesh/nodes'
|
url: '{{ atl_proxy_name }}/rest/api/latest/admin/git/mesh/nodes'
|
||||||
method: GET
|
method: GET
|
||||||
@@ -15,31 +15,31 @@
|
|||||||
delay: 10
|
delay: 10
|
||||||
no_log: True # http headers contain auth strings
|
no_log: True # http headers contain auth strings
|
||||||
|
|
||||||
- name: set bitbucket dc cluster available fact
|
- name: Set Bitbucket DC cluster available fact
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
bitbucket_cluster_available: true
|
bitbucket_cluster_available: true
|
||||||
|
|
||||||
- name: print out the mesh_nodes_report
|
- name: Print out the mesh_nodes_report
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ mesh_nodes_report.json }}"
|
msg: "{{ mesh_nodes_report.json }}"
|
||||||
when:
|
when:
|
||||||
- mesh_nodes_report.status == 200
|
- mesh_nodes_report.status == 200
|
||||||
|
|
||||||
- name: set mesh_nodenames_list
|
- name: Set mesh_nodenames_list fact
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_nodenames_list: "{{ mesh_nodes_report | json_query('json[*].name') }}"
|
mesh_nodenames_list: "{{ mesh_nodes_report | json_query('json[*].name') }}"
|
||||||
when: mesh_nodes_report.status == 200
|
when: mesh_nodes_report.status == 200
|
||||||
|
|
||||||
- name: print out the mesh_nodenames_list
|
- name: Print out the mesh_nodenames_list
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: mesh_nodenames_list
|
var: mesh_nodenames_list
|
||||||
when: mesh_nodes_report.status == 200
|
when: mesh_nodes_report.status == 200
|
||||||
|
|
||||||
rescue:
|
rescue:
|
||||||
- name: set bitbucket dc cluster available fact
|
- name: Set Bitbucket DC cluster available fact
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
bitbucket_cluster_available: false
|
bitbucket_cluster_available: false
|
||||||
|
|
||||||
- name: log a message about bb cluster unavailable
|
- name: Log a message about Bitbucket DC cluster unavailable
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Bitbucket DC cluster not currently available."
|
msg: "Bitbucket DC cluster not currently available."
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
become: false
|
become: false
|
||||||
register: mesh_service_waiter
|
register: mesh_service_waiter
|
||||||
|
|
||||||
- name: trigger the handler to update this existing mesh node
|
- name: Trigger the handler to update this existing mesh node
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||||
changed_when: true
|
changed_when: true
|
||||||
notify: update_mesh_node
|
notify: Update Mesh Node
|
||||||
when:
|
when:
|
||||||
- bitbucket_cluster_available
|
- bitbucket_cluster_available
|
||||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
query: "[?name=='{{ mesh_node_name }}']"
|
query: "[?name=='{{ mesh_node_name }}']"
|
||||||
|
|
||||||
# if node.id doesnt exist this is new/clean mesh node and we need to register a new node
|
# 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
|
- name: If this node is not registered, cleanup any old keys to allow registration of new
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ atl_product_home }}/config/{{ item }}"
|
path: "{{ atl_product_home }}/config/{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
@@ -44,12 +44,12 @@
|
|||||||
vars:
|
vars:
|
||||||
query: "[?name=='{{ mesh_node_name }}']"
|
query: "[?name=='{{ mesh_node_name }}']"
|
||||||
|
|
||||||
- name: trigger the handler to register this new mesh node
|
- name: Trigger the handler to register this new mesh node
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||||
changed_when: true
|
changed_when: true
|
||||||
notify: register_mesh_node
|
notify: Register Mesh Node
|
||||||
when:
|
when:
|
||||||
- bitbucket_cluster_available
|
- bitbucket_cluster_available
|
||||||
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
- mesh_nodes_report.json | community.general.json_query(query) | length == 0
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
- pem_chown.failed | bool
|
- pem_chown.failed | bool
|
||||||
- "'No such file or directory' not in pem_chown.msg"
|
- "'No such file or directory' not in pem_chown.msg"
|
||||||
|
|
||||||
- name: touch mesh.properties to make sure it exists
|
- name: Touch mesh.properties to make sure it exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: touch
|
state: touch
|
||||||
path: "{{ mesh_properties_file }}"
|
path: "{{ mesh_properties_file }}"
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
mode: 0600
|
mode: 0600
|
||||||
|
|
||||||
# check for lines starting with '!' and prefix them with #
|
# check for lines starting with '!' and prefix them with #
|
||||||
- name: prefix properties files bangs with hashes
|
- name: Prefix properties files bangs with hashes
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: "{{ mesh_properties_file }}"
|
path: "{{ mesh_properties_file }}"
|
||||||
regexp: '^(\!.*)$'
|
regexp: '^(\!.*)$'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# if we dont have mesh_vol then we need to either hydrate one from snap or make a new/empty one
|
# if we dont have mesh_vol then we need to either hydrate one from snap or make a new/empty one
|
||||||
|
|
||||||
# first, try to set mesh_vol from currently mounted volume
|
# first, try to set mesh_vol from currently mounted volume
|
||||||
- name: create list of current mounts
|
- name: Create list of current mounts
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mounts_list: "{{ ansible_mounts | map(attribute='mount') | list }}"
|
mounts_list: "{{ ansible_mounts | map(attribute='mount') | list }}"
|
||||||
|
|
||||||
@@ -29,27 +29,27 @@
|
|||||||
get_attributes: yes
|
get_attributes: yes
|
||||||
register: mesh_device_stat
|
register: mesh_device_stat
|
||||||
|
|
||||||
- name: describe mesh volume true device
|
- name: Describe mesh volume true device
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_device: "{{ mesh_device_stat.stat['lnk_source'] }}"
|
mesh_device: "{{ mesh_device_stat.stat['lnk_source'] }}"
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
when: '"lnk_source" in mesh_device_stat.stat'
|
when: '"lnk_source" in mesh_device_stat.stat'
|
||||||
|
|
||||||
# lazy guess at mesh_vol - # TODO make this better
|
# lazy guess at mesh_vol - # TODO make this better
|
||||||
- name: set mesh_vol from currently mounted device
|
- name: Set mesh_vol from currently mounted device
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_vol: "{{ ec2_instance_facts.instances[0] | community.general.json_query(vol_id_query) | first }}"
|
mesh_vol: "{{ ec2_instance_facts.instances[0] | community.general.json_query(vol_id_query) | first }}"
|
||||||
vars:
|
vars:
|
||||||
vol_id_query: "block_device_mappings[?(@.device_name=='/dev/xvdd')].ebs.volume_id"
|
vol_id_query: "block_device_mappings[?(@.device_name=='/dev/xvdd')].ebs.volume_id"
|
||||||
when: (mesh_device is defined) and (mesh_device|length > 0)
|
when: (mesh_device is defined) and (mesh_device | length > 0)
|
||||||
|
|
||||||
- name: shall we check for abandoned?
|
- name: Determine whether we should check for an abandoned EBS volume
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
abandoned_check: "{{ ((mesh_vol is not defined) or (mesh_vol|length == 0)) | ternary(true, false) }}"
|
abandoned_check: "{{ ((mesh_vol is not defined) or (mesh_vol | length == 0)) | ternary(true, false) }}"
|
||||||
|
|
||||||
# second, if we dont have a mesh_vol yet, try to set it from abandoned
|
# second, if we dont have a mesh_vol yet, try to set it from abandoned
|
||||||
- block:
|
- block:
|
||||||
- name: check for abandoned ebs vols of this stack in current AZ
|
- name: Check for abandoned EBS volumes of this stack in current AZ
|
||||||
amazon.aws.ec2_vol_info:
|
amazon.aws.ec2_vol_info:
|
||||||
region: "{{ ansible_ec2_placement_region }}"
|
region: "{{ ansible_ec2_placement_region }}"
|
||||||
filters:
|
filters:
|
||||||
@@ -63,21 +63,21 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
orphan_vol_list: "{{ orphan_vol_info | json_query('volumes[*].id') }}"
|
orphan_vol_list: "{{ orphan_vol_info | json_query('volumes[*].id') }}"
|
||||||
|
|
||||||
- name: loop to get an orphan_lease_lock (temporary lock on volume cleaned up in handler)
|
- name: Loop to get an orphan_lease_lock (temporary lock on volume cleaned up in handler)
|
||||||
ansible.builtin.include_tasks: orphan_lease_lock.yml
|
ansible.builtin.include_tasks: orphan_lease_lock.yml
|
||||||
with_items: "{{ orphan_vol_list }}"
|
with_items: "{{ orphan_vol_list }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_orphan_vol
|
loop_var: test_orphan_vol
|
||||||
when: orphan_vol is not defined
|
when: orphan_vol is not defined
|
||||||
|
|
||||||
- name: set mesh_vol from orphan_vol
|
- name: Set mesh_vol from orphan_vol
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_vol: "{{ orphan_vol }}"
|
mesh_vol: "{{ orphan_vol }}"
|
||||||
when:
|
when:
|
||||||
- orphan_vol is defined
|
- orphan_vol is defined
|
||||||
- orphan_vol | length > 0
|
- orphan_vol | length > 0
|
||||||
|
|
||||||
- name: attach abandoned mesh vol to this ec2
|
- name: Attach abandoned mesh vol to this ec2
|
||||||
amazon.aws.ec2_vol:
|
amazon.aws.ec2_vol:
|
||||||
instance: "{{ ansible_ec2_instance_id }}"
|
instance: "{{ ansible_ec2_instance_id }}"
|
||||||
id: "{{ mesh_vol }}"
|
id: "{{ mesh_vol }}"
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
|
|
||||||
# third, if no mesh_vol and this is a clone, set mesh_snap
|
# third, if no mesh_vol and this is a clone, set mesh_snap
|
||||||
- block:
|
- block:
|
||||||
- name: create az dict attributes
|
- name: Create AZ dict attributes
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
my_attributes:
|
my_attributes:
|
||||||
- key: "{{ atl_mesh_azname_az1 }}"
|
- key: "{{ atl_mesh_azname_az1 }}"
|
||||||
@@ -102,15 +102,15 @@
|
|||||||
- key: "{{ atl_mesh_azname_az3 }}"
|
- key: "{{ atl_mesh_azname_az3 }}"
|
||||||
value: "{{ atl_mesh_snapshot_az3 }}"
|
value: "{{ atl_mesh_snapshot_az3 }}"
|
||||||
|
|
||||||
- name: create az dict if this stack is a mesh clone
|
- name: Create AZ dict if this stack is a mesh clone
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
azsnapdict: "{{ my_attributes | items2dict }}"
|
azsnapdict: "{{ my_attributes | items2dict }}"
|
||||||
|
|
||||||
- name: set mesh clone node snapshot fact if this stack is a mesh clone
|
- name: Set mesh clone node snapshot fact if this stack is a mesh clone
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_snapshot: "{{ azsnapdict[ansible_ec2_placement_availability_zone] }}"
|
mesh_snapshot: "{{ azsnapdict[ansible_ec2_placement_availability_zone] }}"
|
||||||
|
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
when:
|
when:
|
||||||
- (mesh_vol is not defined) or (mesh_vol|length == 0)
|
- (mesh_vol is not defined) or (mesh_vol | length == 0)
|
||||||
- mesh_clone
|
- mesh_clone
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
# hydrate mesh volume from snapshot or create empty one if no snapshot set
|
# hydrate mesh volume from snapshot or create empty one if no snapshot set
|
||||||
- name: create new ebs from snapshot for this mesh node with correct tags
|
- name: Create new EBS from snapshot for this mesh node with correct tags
|
||||||
amazon.aws.ec2_vol:
|
amazon.aws.ec2_vol:
|
||||||
region: "{{ ansible_ec2_placement_region }}"
|
region: "{{ ansible_ec2_placement_region }}"
|
||||||
instance: "{{ ansible_ec2_instance_id }}"
|
instance: "{{ ansible_ec2_instance_id }}"
|
||||||
@@ -13,16 +13,16 @@
|
|||||||
Name: "{{ atl_aws_stack_name }} mesh volume {{ ansible_ec2_placement_availability_zone }}"
|
Name: "{{ atl_aws_stack_name }} mesh volume {{ ansible_ec2_placement_availability_zone }}"
|
||||||
volume_type: "mesh"
|
volume_type: "mesh"
|
||||||
register: mesh_vol_info
|
register: mesh_vol_info
|
||||||
when: (mesh_snapshot is defined) and (mesh_snapshot|length > 0)
|
when: (mesh_snapshot is defined) and (mesh_snapshot | length > 0)
|
||||||
|
|
||||||
- name: set mesh_vol from info of vol created from snapshot
|
- name: Set mesh_vol from info of vol created from snapshot
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_vol: "{{ mesh_vol_info.volume_id }}"
|
mesh_vol: "{{ mesh_vol_info.volume_id }}"
|
||||||
new_meshvol_from_snap: true
|
new_meshvol_from_snap: true
|
||||||
when: (mesh_snapshot is defined) and (mesh_snapshot|length > 0)
|
when: (mesh_snapshot is defined) and (mesh_snapshot | length > 0)
|
||||||
|
|
||||||
# if we still dont have mesh_vol, create new/empty one
|
# if we still dont have mesh_vol, create new/empty one
|
||||||
- name: final choice - create empty mesh_vol
|
- name: Create new/empty mesh volume
|
||||||
amazon.aws.ec2_vol:
|
amazon.aws.ec2_vol:
|
||||||
region: "{{ ansible_ec2_placement_region }}"
|
region: "{{ ansible_ec2_placement_region }}"
|
||||||
instance: "{{ ansible_ec2_instance_id }}"
|
instance: "{{ ansible_ec2_instance_id }}"
|
||||||
@@ -36,14 +36,13 @@
|
|||||||
Name: "{{ atl_aws_stack_name }} mesh volume {{ ansible_ec2_placement_availability_zone }}"
|
Name: "{{ atl_aws_stack_name }} mesh volume {{ ansible_ec2_placement_availability_zone }}"
|
||||||
volume_type: "mesh"
|
volume_type: "mesh"
|
||||||
register: mesh_vol_info
|
register: mesh_vol_info
|
||||||
when: (mesh_snapshot is not defined) or (mesh_snapshot|length == 0)
|
when: (mesh_snapshot is not defined) or (mesh_snapshot | length == 0)
|
||||||
|
|
||||||
- name: set mesh_vol from info of created
|
- name: Set mesh_vol from info of created volume
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_vol: "{{ mesh_vol_info.volume_id }}"
|
mesh_vol: "{{ mesh_vol_info.volume_id }}"
|
||||||
when: (mesh_snapshot is not defined) or (mesh_snapshot|length == 0)
|
when: (mesh_snapshot is not defined) or (mesh_snapshot | length == 0)
|
||||||
|
|
||||||
# we should always have mesh_vol by now, if not, Barf !
|
- name: Log mesh_vol
|
||||||
- name: we should always have mesh_vol by now
|
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: mesh_vol
|
var: mesh_vol
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
# rerun the mesh volume stat now that we _really_ should have the volume
|
# rerun the mesh volume stat now that we _really_ should have the volume
|
||||||
- name: discover mesh volume device stat
|
- name: Discover mesh volume device stat
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: '/dev/xvdd'
|
path: '/dev/xvdd'
|
||||||
follow: no
|
follow: no
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
delay: 10
|
delay: 10
|
||||||
until: mesh_device_stat.stat['lnk_source'] is defined
|
until: mesh_device_stat.stat['lnk_source'] is defined
|
||||||
|
|
||||||
- name: describe mesh volume true device
|
- name: Describe mesh volume true device
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_device: "{{ mesh_device_stat.stat['lnk_source'] }}"
|
mesh_device: "{{ mesh_device_stat.stat['lnk_source'] }}"
|
||||||
|
|
||||||
- name: check mesh, caches and logs filetypes
|
- name: Check mesh, caches and logs filetypes
|
||||||
community.general.parted:
|
community.general.parted:
|
||||||
device: "{{ item }}"
|
device: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
@@ -23,20 +23,20 @@
|
|||||||
- "{{ mesh_device }}"
|
- "{{ mesh_device }}"
|
||||||
register: filesystem_types
|
register: filesystem_types
|
||||||
|
|
||||||
- name: set filesystem type fact for mesh volume
|
- name: Set filesystem type fact for mesh volume
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mesh_filesystem: "{{ filesystem_types.results | community.general.json_query(query) }}"
|
mesh_filesystem: "{{ filesystem_types.results | community.general.json_query(query) }}"
|
||||||
vars:
|
vars:
|
||||||
query: "[?item=='{{ mesh_device }}'].partitions[0].fstype"
|
query: "[?item=='{{ mesh_device }}'].partitions[0].fstype"
|
||||||
|
|
||||||
- name: ensure mesh volume has a filesystem
|
- name: Ensure mesh volume has a filesystem
|
||||||
community.general.filesystem:
|
community.general.filesystem:
|
||||||
dev: "{{ mesh_device }}"
|
dev: "{{ mesh_device }}"
|
||||||
fstype: "{{ fstype }}"
|
fstype: "{{ fstype }}"
|
||||||
vars:
|
vars:
|
||||||
fstype: "{{ (mesh_filesystem|length > 0) | ternary(mesh_filesystem[0], 'xfs') }}"
|
fstype: "{{ (mesh_filesystem | length > 0) | ternary(mesh_filesystem[0], 'xfs') }}"
|
||||||
|
|
||||||
- name: ensure caches and logs volumes have filesystem
|
- name: Ensure caches and logs volumes have filesystem
|
||||||
community.general.filesystem:
|
community.general.filesystem:
|
||||||
dev: "{{ item }}"
|
dev: "{{ item }}"
|
||||||
fstype: "xfs"
|
fstype: "xfs"
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
- /dev/nvme1n1
|
- /dev/nvme1n1
|
||||||
- /dev/nvme2n1
|
- /dev/nvme2n1
|
||||||
|
|
||||||
- name: mount mesh vol to atl_product_home
|
- name: Mount mesh vol to atl_product_home
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: "{{ atl_product_home }}"
|
path: "{{ atl_product_home }}"
|
||||||
src: '/dev/xvdd'
|
src: '/dev/xvdd'
|
||||||
@@ -52,16 +52,16 @@
|
|||||||
state: mounted
|
state: mounted
|
||||||
register: xfs_mesh_mount
|
register: xfs_mesh_mount
|
||||||
vars:
|
vars:
|
||||||
fstype: "{{ (mesh_filesystem|length > 0) | ternary(mesh_filesystem[0], 'xfs') }}"
|
fstype: "{{ (mesh_filesystem | length > 0) | ternary(mesh_filesystem[0], 'xfs') }}"
|
||||||
|
|
||||||
- name: mount cache to atl_product_home/caches
|
- name: Mount cache to atl_product_home/caches
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: "{{ atl_product_home }}/caches"
|
path: "{{ atl_product_home }}/caches"
|
||||||
src: '/dev/xvdb'
|
src: '/dev/xvdb'
|
||||||
fstype: xfs
|
fstype: xfs
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
||||||
- name: mount log to atl_product_home/log
|
- name: Mount log to atl_product_home/log
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: "{{ atl_product_home }}/log"
|
path: "{{ atl_product_home }}/log"
|
||||||
src: '/dev/xvdc'
|
src: '/dev/xvdc'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: try to create lease_lock directory in efs for this test_orphan_vol
|
- name: Try to create lease_lock directory in EFS for this test_orphan_vol
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: '{{ atl_shared_mountpoint }}/.{{ test_orphan_vol }}'
|
path: '{{ atl_shared_mountpoint }}/.{{ test_orphan_vol }}'
|
||||||
state: directory
|
state: directory
|
||||||
@@ -12,9 +12,9 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
orphan_vol: '{{ test_orphan_vol }}'
|
orphan_vol: '{{ test_orphan_vol }}'
|
||||||
changed_when: true
|
changed_when: true
|
||||||
notify: Remove orphan_vol lease_lock
|
notify: Remove orphan_vol lease lock
|
||||||
when:
|
when:
|
||||||
- orphan_vol is not defined
|
- orphan_vol is not defined
|
||||||
- orphan_vol_lease_lock is defined
|
- orphan_vol_lease_lock is defined
|
||||||
- orphan_vol_lease_lock.changed
|
- orphan_vol_lease_lock.changed
|
||||||
tags: molecule-idempotence-notest
|
tags: molecule-idempotence-notest
|
||||||
|
|||||||
Reference in New Issue
Block a user