diff --git a/Pipfile b/Pipfile index 7742861..34de04c 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ cryptography = "==41.0.6" boto3 = "==1.26.158" botocore = "==1.29.158" lxml = "==4.9.2" +netaddr = "==0.9.0" psycopg2-binary = "==2.9.6" petname = "==2.6" diff --git a/Pipfile.lock b/Pipfile.lock index 4c49b4f..6686cc2 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "10f558f28137bc8cd19b08b05fca3f421f4a571aa2f50129aa1b142f074a4907" + "sha256": "d51bfb4e5f729e549956f267562dc203d4983d84c6fed34862ab64785343e289" }, "pipfile-spec": 6, "requires": { @@ -297,6 +297,14 @@ "markers": "python_version >= '3.7'", "version": "==2.1.5" }, + "netaddr": { + "hashes": [ + "sha256:5148b1055679d2a1ec070c521b7db82137887fabd6d7e37f5199b44f775c3bb1", + "sha256:7b46fa9b1a2d71fd5de9e4a3784ef339700a53a08c8040f08baf5f1194da0128" + ], + "index": "pypi", + "version": "==0.9.0" + }, "packaging": { "hashes": [ "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", diff --git a/group_vars/aws_node_local.yml b/group_vars/aws_node_local.yml index 52ff9b3..4fcf44e 100644 --- a/group_vars/aws_node_local.yml +++ b/group_vars/aws_node_local.yml @@ -132,6 +132,7 @@ atl_proxy_port: "{{ lookup('env', 'ATL_TOMCAT_PROXYPORT') }}" atl_tomcat_port: "{{ lookup('env', 'ATL_TOMCAT_DEFAULTCONNECTORPORT') or '8080' }}" atl_ssl_proxy: "{{ lookup('env', 'ATL_SSL_PROXY') or 'false' }}" atl_apptunnel_port: "{{ lookup('env', 'ATL_APPTUNNEL_PORT') or '' }}" +atl_hostedzone: "{{ lookup('env', 'ATL_HOSTEDZONE') or '' }}" atl_tomcat_acceptcount: "{{ lookup('env', 'ATL_TOMCAT_ACCEPTCOUNT') or '10' }}" atl_tomcat_connectiontimeout: "{{ lookup('env', 'ATL_TOMCAT_CONNECTIONTIMEOUT') or '20000' }}" diff --git a/requirements.yml b/requirements.yml index 55533fd..9ba1626 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,5 +1,7 @@ --- collections: + - name: ansible.utils + version: "3.1.0" - name: amazon.aws version: "6.1.0" - name: ansible.posix diff --git a/roles/bitbucket_mesh_config/defaults/main.yml b/roles/bitbucket_mesh_config/defaults/main.yml index 60f7495..493f907 100644 --- a/roles/bitbucket_mesh_config/defaults/main.yml +++ b/roles/bitbucket_mesh_config/defaults/main.yml @@ -1,6 +1,11 @@ --- -bitbucket_mesh_maven_repo: https://packages.atlassian.com/maven-external -bitbucket_mesh_version: "1.3.1" -mesh_properties_file: "{{ atl_product_home }}/mesh.properties" -mesh_node_scheme: "http" +atl_mesh_volume_size: "{{ lookup('env', 'ATL_MESH_VOLUME_SIZE') or '50' }}" +atl_mesh_azname_az1: "{{ lookup('env', 'ATL_MESH_AZNAME_AZ1') or '' }}" +atl_mesh_azname_az2: "{{ lookup('env', 'ATL_MESH_AZNAME_AZ2') or '' }}" +atl_mesh_azname_az3: "{{ lookup('env', 'ATL_MESH_AZNAME_AZ3') or '' }}" +atl_mesh_snapshot_az1: "{{ lookup('env', 'ATL_MESH_SNAPSHOT_AZ1') or '' }}" +atl_mesh_snapshot_az2: "{{ lookup('env', 'ATL_MESH_SNAPSHOT_AZ2') or '' }}" +atl_mesh_snapshot_az3: "{{ lookup('env', 'ATL_MESH_SNAPSHOT_AZ3') or '' }}" mesh_node_port: "7777" +mesh_node_scheme: "http" +mesh_properties_file: "{{ atl_product_home }}/mesh.properties" diff --git a/roles/bitbucket_mesh_config/tasks/main.yml b/roles/bitbucket_mesh_config/tasks/main.yml index 231fcfa..08b08a7 100644 --- a/roles/bitbucket_mesh_config/tasks/main.yml +++ b/roles/bitbucket_mesh_config/tasks/main.yml @@ -2,7 +2,7 @@ - name: Touch the JMX password file ansible.builtin.file: - path: "{{ atl_home_base }}/{{ atl_product_edition }}/jmx.access" + path: "{{ atl_product_home }}/jmx.access" state: touch owner: "{{ atl_product_user }}" group: "{{ atl_product_user }}" @@ -74,7 +74,7 @@ - name: set mesh_node_id var from the existing mesh.properties file 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 }}") ansible.builtin.set_fact: @@ -104,7 +104,7 @@ # handle reregistering the correct node if node.id exists - name: set mesh_node_id var from the existing mesh.properties file 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 - name: mesh service related processing diff --git a/roles/bitbucket_mesh_config/tasks/mesh_newpet.yml b/roles/bitbucket_mesh_config/tasks/mesh_newpet.yml index 1210a85..35ec172 100644 --- a/roles/bitbucket_mesh_config/tasks/mesh_newpet.yml +++ b/roles/bitbucket_mesh_config/tasks/mesh_newpet.yml @@ -5,7 +5,7 @@ - name: set mesh_node_name var from the existing mesh.properties file 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] ansible.builtin.set_fact: diff --git a/roles/bitbucket_mesh_config/tasks/mesh_service.yml b/roles/bitbucket_mesh_config/tasks/mesh_service.yml index 8a0995b..92c8d3d 100644 --- a/roles/bitbucket_mesh_config/tasks/mesh_service.yml +++ b/roles/bitbucket_mesh_config/tasks/mesh_service.yml @@ -32,7 +32,7 @@ # 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 ansible.builtin.file: - path: "{{ atl_home_base }}/{{ atl_product_edition }}/config/{{ item }}" + path: "{{ atl_product_home }}/config/{{ item }}" state: absent with_items: - signing-key.pem diff --git a/roles/bitbucket_mesh_config/tasks/meshvol_check.yml b/roles/bitbucket_mesh_config/tasks/meshvol_check.yml index 81a1873..04ceb90 100644 --- a/roles/bitbucket_mesh_config/tasks/meshvol_check.yml +++ b/roles/bitbucket_mesh_config/tasks/meshvol_check.yml @@ -8,22 +8,21 @@ ansible.builtin.set_fact: mounts_list: "{{ ansible_mounts | map(attribute='mount') | list }}" -# - name: discover mesh volume device stat -# ansible.builtin.stat: -# path: '/dev/xvdd' -# follow: no -# get_attributes: yes -# register: mesh_device_stat +- name: Retrieve info for this instance from EC2 + amazon.aws.ec2_instance_info: + region: "{{ ansible_ec2_placement_region }}" + instance_ids: + - "{{ ansible_ec2_instance_id }}" + retries: 10 + delay: 10 + register: ec2_instance_facts + until: ec2_instance_facts.error is not defined -- name: pull info for this_instance from instanceFacts +- name: Create list of current block devices attached to this instance ansible.builtin.set_fact: - this_instance: "{{ instanceFacts.instances | first }}" + devices_list: "{{ ec2_instance_facts.instances[0].block_device_mappings | map(attribute='device_name') | list }}" -- name: create list of current block devices - ansible.builtin.set_fact: - devices_list: "{{ this_instance.block_device_mappings | map(attribute='device_name') | list }}" - -- name: discover mesh volume device stat +- name: Discover mesh volume device stat ansible.builtin.stat: path: '/dev/xvdd' follow: no @@ -39,7 +38,7 @@ # lazy guess at mesh_vol - # TODO make this better - name: set mesh_vol from currently mounted device ansible.builtin.set_fact: - mesh_vol: "{{ this_instance | community.general.json_query(vol_id_query) | first }}" + mesh_vol: "{{ ec2_instance_facts.instances[0] | community.general.json_query(vol_id_query) | first }}" vars: vol_id_query: "block_device_mappings[?(@.device_name=='/dev/xvdd')].ebs.volume_id" when: (mesh_device is defined) and (mesh_device|length > 0)