mirror of
https://github.com/ZwareBear/JFrog-Cloud-Installers.git
synced 2026-01-21 06:06:56 -06:00
148 lines
5.0 KiB
YAML
148 lines
5.0 KiB
YAML
---
|
|
- name: Provision AWS test infrastructure
|
|
hosts: localhost
|
|
tasks:
|
|
- shell: 'pwd'
|
|
register: cmd
|
|
|
|
- debug:
|
|
msg: "{{ cmd.stdout }}"
|
|
- name: Create AWS test system
|
|
cloudformation:
|
|
stack_name: "{{ lookup('env', 'stack_name') }}"
|
|
state: "present"
|
|
region: "us-east-1"
|
|
disable_rollback: true
|
|
template: "{{ lookup('env', 'cfn_template') }}"
|
|
template_parameters:
|
|
SSHKeyName: "{{ lookup('env', 'ssh_public_key_name') }}"
|
|
tags:
|
|
Stack: "{{ lookup('env', 'stack_name') }}"
|
|
register: AWSDeployment
|
|
- name: Get AWS deployment details
|
|
debug:
|
|
var: AWSDeployment
|
|
|
|
- name: Add bastion
|
|
add_host:
|
|
hostname: "{{ AWSDeployment.stack_outputs.BastionInstancePublic }}"
|
|
groups: bastion
|
|
ansible_user: "ubuntu"
|
|
- name: Add new RT primary to host group
|
|
add_host:
|
|
hostname: "{{ AWSDeployment.stack_outputs.RTPriInstancePrivate }}"
|
|
ansible_user: "ubuntu"
|
|
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -A ubuntu@{{ AWSDeployment.stack_outputs.BastionInstancePublic }} -W %h:%p"'
|
|
db_url: "jdbc:postgresql://{{ AWSDeployment.stack_outputs.DBInstancePrivate }}:5432/artifactory"
|
|
server_name: "{{ AWSDeployment.stack_outputs.ALBHostName }}"
|
|
artifactory_is_primary: true
|
|
artifactory_license1: "{{ lookup('env', 'artifactory_license1') }}"
|
|
artifactory_license2: "{{ lookup('env', 'artifactory_license2') }}"
|
|
artifactory_license3: "{{ lookup('env', 'artifactory_license3') }}"
|
|
groups:
|
|
- artifactory
|
|
|
|
- name: Add RT secondaries to host group
|
|
add_host:
|
|
hostname: "{{ AWSDeployment.stack_outputs.RTSecInstancePrivate }}"
|
|
ansible_user: "ubuntu"
|
|
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -A ubuntu@{{ AWSDeployment.stack_outputs.BastionInstancePublic }} -W %h:%p"'
|
|
db_url: "jdbc:postgresql://{{ AWSDeployment.stack_outputs.DBInstancePrivate }}:5432/artifactory"
|
|
server_name: "{{ AWSDeployment.stack_outputs.ALBHostName }}"
|
|
artifactory_is_primary: false
|
|
groups:
|
|
- artifactory
|
|
|
|
- name: Add xrays to host group
|
|
add_host:
|
|
hostname: "{{ AWSDeployment.stack_outputs.XrayInstancePrivate }}"
|
|
ansible_user: "ubuntu"
|
|
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -A ubuntu@{{ AWSDeployment.stack_outputs.BastionInstancePublic }} -W %h:%p"'
|
|
jfrog_url: "http://{{ AWSDeployment.stack_outputs.ALBHostName }}"
|
|
master_key: "{{ lookup('env', 'master_key') }}"
|
|
join_key: "{{ lookup('env', 'join_key') }}"
|
|
db_type: "postgresql"
|
|
db_driver: "org.postgresql.Driver"
|
|
db_user: "xray"
|
|
db_password: "xray"
|
|
db_url: "postgres://{{ AWSDeployment.stack_outputs.DBInstancePrivate }}:5432/xraydb?sslmode=disable"
|
|
groups: xray
|
|
|
|
- name: Add DBs to host group
|
|
add_host:
|
|
hostname: "{{ AWSDeployment.stack_outputs.DBInstancePrivate }}"
|
|
ansible_user: "ubuntu"
|
|
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -A ubuntu@{{ AWSDeployment.stack_outputs.BastionInstancePublic }} -W %h:%p"'
|
|
db_users:
|
|
- { db_user: "artifactory", db_password: "Art1fAct0ry" }
|
|
- { db_user: "xray", db_password: "xray" }
|
|
dbs:
|
|
- { db_name: "artifactory", db_owner: "artifactory" }
|
|
- { db_name: "xraydb", db_owner: "xray" }
|
|
groups: database
|
|
|
|
- name: Set up test environment url
|
|
replace:
|
|
path: ../tests/src/test/resources/testenv.yaml
|
|
regexp: 'urlval'
|
|
replace: "http://{{ AWSDeployment.stack_outputs.ALBHostName }}"
|
|
|
|
- name: Set up test environment external_ip
|
|
replace:
|
|
path: ../tests/src/test/resources/testenv.yaml
|
|
regexp: 'ipval'
|
|
replace: "{{ AWSDeployment.stack_outputs.ALBHostName }}"
|
|
|
|
- name: Set up test environment rt_password
|
|
replace:
|
|
path: ../tests/src/test/resources/testenv.yaml
|
|
regexp: 'passval'
|
|
replace: "password"
|
|
|
|
- name: show testenv.yaml
|
|
debug: var=item
|
|
with_file:
|
|
- ../tests/src/test/resources/testenv.yaml
|
|
|
|
- name: Wait 300 seconds for port 22
|
|
wait_for:
|
|
port: 22
|
|
host: "{{ AWSDeployment.stack_outputs.BastionInstancePublic }}"
|
|
delay: 10
|
|
|
|
- debug:
|
|
msg: "Unified URL is at http://{{ AWSDeployment.stack_outputs.ALBHostName }}"
|
|
|
|
- hosts: database
|
|
roles:
|
|
- postgres
|
|
|
|
- hosts: artifactory
|
|
vars:
|
|
artifactory_ha_enabled: true
|
|
master_key: "{{ lookup('env', 'master_key') }}"
|
|
join_key: "{{ lookup('env', 'join_key') }}"
|
|
db_download_url: "https://jdbc.postgresql.org/download/postgresql-42.2.12.jar"
|
|
db_type: "postgresql"
|
|
db_driver: "org.postgresql.Driver"
|
|
db_user: "artifactory"
|
|
db_password: "Art1fAct0ry"
|
|
roles:
|
|
- artifactory
|
|
|
|
- hosts: xray
|
|
roles:
|
|
- xray
|
|
|
|
- name: Test
|
|
hosts: localhost
|
|
tasks:
|
|
- name: Run tests
|
|
shell:
|
|
cmd: ./gradlew clean unified_test
|
|
chdir: ../tests/
|
|
- name: Cleanup and delete stack
|
|
cloudformation:
|
|
stack_name: "{{ lookup('env', 'stack_name') }}"
|
|
region: "us-east-1"
|
|
state: "absent" |