mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-16 18:03:06 -06:00
Added Ansible playbook to upgrade ZDU bitbucket
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
[defaults]
|
||||
retry_files_enabled = False
|
||||
callback_whitelist = profile_tasks
|
||||
|
||||
[inventory]
|
||||
enable_plugin = aws_ec2
|
||||
|
||||
62
aws_bitbucket_cluster_zdu.yml
Normal file
62
aws_bitbucket_cluster_zdu.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
vars_files: group_vars/aws_node_local.yml
|
||||
roles:
|
||||
- role: bitbucket_zdu_init
|
||||
|
||||
- hosts: all
|
||||
serial: 1
|
||||
any_errors_fatal: true
|
||||
vars_files: group_vars/aws_node_local.yml
|
||||
vars:
|
||||
# See group_vars/aws_node_local.yml, which pull vars from the environment.
|
||||
atl_product_family: "stash"
|
||||
atl_product_edition: "bitbucket"
|
||||
atl_product_user: "bitbucket"
|
||||
|
||||
atl_product_home: "{{ atl_shared_mountpoint }}/{{ atl_product_edition }}"
|
||||
|
||||
atl_nfs_mountpoint: "{{ atl_shared_mountpoint }}/bitbucket/shared"
|
||||
atl_nfs_target: "{{ atl_shared_mountpoint }}/bitbucket/shared"
|
||||
atl_nfs_version: "3"
|
||||
|
||||
atl_startup_systemd_params:
|
||||
- "UMask=0027"
|
||||
- "LimitNOFILE=4096"
|
||||
- "Environment=BITBUCKET_HOME={{ atl_product_home }}"
|
||||
- "Environment=JVM_MAXIMUM_MEMORY={{ atl_jvm_heap }}"
|
||||
- "Environment=JVM_MINIMUM_MEMORY={{ atl_jvm_heap }}"
|
||||
- "Environment=JVM_SUPPORT_RECOMMENDED_ARGS={{ atl_jvm_opts }}"
|
||||
atl_startup_exec_options:
|
||||
- "-fg"
|
||||
- "--no-search"
|
||||
pre_tasks:
|
||||
- name: Stop bitbucket
|
||||
service:
|
||||
name: "{{ atl_systemd_service_name }}"
|
||||
state: stopped
|
||||
roles:
|
||||
- role: aws_common
|
||||
- role: product_common
|
||||
- role: product_install
|
||||
- role: bitbucket_config
|
||||
- role: product_startup
|
||||
post_tasks:
|
||||
- name: Wait for node to finish startup
|
||||
uri:
|
||||
url: "{{ atl_tomcat_scheme }}://127.0.0.1:{{ atl_tomcat_port }}{{ atl_tomcat_contextpath }}/status"
|
||||
method: GET
|
||||
status_code: 200
|
||||
register: bitbucket_state
|
||||
failed_when: bitbucket_state.json is not defined or (bitbucket_state.json is defined and bitbucket_state.json.state != 'RUNNING')
|
||||
until: bitbucket_state.json is defined and bitbucket_state.json.state == 'RUNNING'
|
||||
retries: 120
|
||||
delay: 5
|
||||
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
vars_files: group_vars/aws_node_local.yml
|
||||
roles:
|
||||
- role: bitbucket_zdu_finish
|
||||
39
aws_bitbucket_dc_upgrade_node.yml
Normal file
39
aws_bitbucket_dc_upgrade_node.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- hosts: aws_node_local
|
||||
become: true
|
||||
|
||||
vars:
|
||||
# See group_vars/aws_node_local.yml, which pull vars from the environment.
|
||||
atl_product_family: "stash"
|
||||
atl_product_edition: "bitbucket"
|
||||
atl_product_user: "bitbucket"
|
||||
|
||||
atl_product_home: "{{ atl_shared_mountpoint }}/{{ atl_product_edition }}"
|
||||
|
||||
atl_nfs_mountpoint: "{{ atl_shared_mountpoint }}/bitbucket/shared"
|
||||
atl_nfs_target: "{{ atl_shared_mountpoint }}/bitbucket/shared"
|
||||
atl_nfs_version: "3"
|
||||
|
||||
atl_startup_systemd_params:
|
||||
- "UMask=0027"
|
||||
- "LimitNOFILE=4096"
|
||||
- "Environment=BITBUCKET_HOME={{ atl_product_home }}"
|
||||
- "Environment=JVM_MAXIMUM_MEMORY={{ atl_jvm_heap }}"
|
||||
- "Environment=JVM_MINIMUM_MEMORY={{ atl_jvm_heap }}"
|
||||
- "Environment=JVM_SUPPORT_RECOMMENDED_ARGS={{ atl_jvm_opts }}"
|
||||
atl_startup_exec_options:
|
||||
- "-fg"
|
||||
- "--no-search"
|
||||
pre_tasks:
|
||||
- name: Stop bitbucket
|
||||
service:
|
||||
name: "{{ atl_systemd_service_name }}"
|
||||
state: stopped
|
||||
|
||||
roles:
|
||||
# This is needed because it sets the node ID
|
||||
- role: aws_common
|
||||
- role: product_common
|
||||
- role: product_install
|
||||
- role: bitbucket_config
|
||||
- role: product_startup
|
||||
16
inv/alt_cluster_aws_ec2.yml
Normal file
16
inv/alt_cluster_aws_ec2.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
## Creates an inventory from your application cluster autoscaling group
|
||||
## You need to provide the following environment variables
|
||||
# AWS_ACCESS_KEY_ID
|
||||
# AWS_SECRET_ACCESS_KEY
|
||||
#
|
||||
# Replace "your_autoscaling_group" with the name of the EC2 autoscaling group your application cluster is running in
|
||||
# Replace "your deployment region" with the AWS region your cluster is running in
|
||||
# The Ansible controller node will need to have SSH access to the autoscaling group so ensure its private key is authorised and there
|
||||
# the security group allows SSH connection
|
||||
|
||||
plugin: aws_ec2
|
||||
|
||||
filters:
|
||||
tag:aws:autoscaling:groupName: test-nghazali-Bitbucket
|
||||
regions:
|
||||
- ap-southeast-2
|
||||
2
roles/bitbucket_zdu_finish/defaults/main.yml
Normal file
2
roles/bitbucket_zdu_finish/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
atl_bitbucket_baseurl: "{{ atl_tomcat_scheme }}://{{ atl_proxy_name }}{{ atl_tomcat_contextpath }}"
|
||||
atl_bitbucket_zdu_rest_endpoint: "rest/api/2/cluster/zdu"
|
||||
35
roles/bitbucket_zdu_finish/tasks/main.yml
Normal file
35
roles/bitbucket_zdu_finish/tasks/main.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
|
||||
- name: Assert cluster is ready to finalise upgrade
|
||||
uri:
|
||||
url: "{{ atl_bitbucket_baseurl }}/{{ atl_bitbucket_zdu_rest_endpoint }}/state"
|
||||
force_basic_auth: yes
|
||||
user: "{{ bitbucket_admin_username }}"
|
||||
password: "{{ bitbucket_admin_password }}"
|
||||
method: GET
|
||||
status_code: 200
|
||||
register: upgrade_cluster_state
|
||||
failed_when: upgrade_cluster_state.json is not defined or upgrade_cluster_state.json.state != 'READY_TO_RUN_UPGRADE_TASKS'
|
||||
|
||||
- name: Approve cluster upgrade
|
||||
uri:
|
||||
url: "{{ atl_bitbucket_baseurl }}/{{ atl_bitbucket_zdu_rest_endpoint }}/approve"
|
||||
force_basic_auth: yes
|
||||
user: "{{ bitbucket_admin_username }}"
|
||||
password: "{{ bitbucket_admin_password }}"
|
||||
method: POST
|
||||
status_code: 200
|
||||
|
||||
- name: Wait for cluster to finish running upgrade tasks
|
||||
uri:
|
||||
url: "{{ atl_bitbucket_baseurl }}/{{ atl_bitbucket_zdu_rest_endpoint }}/state"
|
||||
force_basic_auth: yes
|
||||
user: "{{ bitbucket_admin_username }}"
|
||||
password: "{{ bitbucket_admin_password }}"
|
||||
method: GET
|
||||
status_code: 200
|
||||
register: post_upgrade_cluster_state
|
||||
failed_when: post_upgrade_cluster_state.json is not defined or post_upgrade_cluster_state.json.state == 'READY_TO_UPGRADE' or post_upgrade_cluster_state.json.state == 'READY_TO_RUN_UPGRADE_TASKS' or post_upgrade_cluster_state.json.state == 'MIXED'
|
||||
until: post_upgrade_cluster_state.json is defined and post_upgrade_cluster_state.json.state == 'STABLE'
|
||||
retries: 120
|
||||
delay: 5
|
||||
2
roles/bitbucket_zdu_init/defaults/main.yml
Normal file
2
roles/bitbucket_zdu_init/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
atl_bitbucket_baseurl: "{{ atl_tomcat_scheme }}://{{ atl_proxy_name }}{{ atl_tomcat_contextpath }}"
|
||||
atl_bitbucket_zdu_rest_endpoint: "rest/api/2/cluster/zdu"
|
||||
32
roles/bitbucket_zdu_init/tasks/main.yml
Normal file
32
roles/bitbucket_zdu_init/tasks/main.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
|
||||
- name: Assert cluster is ready for upgrade
|
||||
uri:
|
||||
url: "{{ atl_bitbucket_baseurl }}/{{ atl_jira_zdu_rest_endpoint }}/state"
|
||||
force_basic_auth: yes
|
||||
user: "{{ bitbucket_admin_username }}"
|
||||
password: "{{ bitbucket_admin_password }}"
|
||||
method: GET
|
||||
status_code: 200
|
||||
register: pre_upgrade_cluster_state
|
||||
|
||||
- name: Begin cluster upgrade
|
||||
uri:
|
||||
url: "{{ atl_bitbucket_baseurl }}/{{ atl_bitbucket_zdu_rest_endpoint }}/start"
|
||||
force_basic_auth: yes
|
||||
user: "{{ bitbucket_admin_username }}"
|
||||
password: "{{ bitbucket_admin_password }}"
|
||||
method: POST
|
||||
status_code: 201
|
||||
when: pre_upgrade_cluster_state.json is defined and pre_upgrade_cluster_state.json.state == 'STABLE'
|
||||
|
||||
- name: Verify cluster ready to upgrade
|
||||
uri:
|
||||
url: "{{ atl_bitbucket_baseurl }}/{{ atl_bitbucket_zdu_rest_endpoint }}/state"
|
||||
force_basic_auth: yes
|
||||
user: "{{ bitbucket_admin_username }}"
|
||||
password: "{{ bitbucket_admin_password }}"
|
||||
method: GET
|
||||
status_code: 200
|
||||
register: upgrade_cluster_state
|
||||
failed_when: upgrade_cluster_state.json is not defined or upgrade_cluster_state.json.state != 'READY_TO_UPGRADE'
|
||||
Reference in New Issue
Block a user