Added support for Artifactory and Xray upgrades. v1.0.8

This commit is contained in:
jefferyfry
2020-08-06 19:35:31 -07:00
parent 4eb074c43e
commit 7517a48339
98 changed files with 460 additions and 8420 deletions

View File

@@ -1,13 +1,6 @@
# JFrog Ansible Installers Collection
This Ansible directory consists of the following directories that support the JFrog Ansible collection.
* [ansible_collections directory](ansible_collections) - This directory contains the Ansible collection package that has the Ansible roles for Artifactory and Xray. See the collection [README](ansible_collections/README.md) for details on the available roles and variables.
* [examples directory](examples) - This directory contains example playbooks for various architectures from single Artifactory (RT) deployments to high-availability setups.
* [infra directory](infra) - This directory contains example infrastructure templates that can be used for testing and as example deployments.
* [test directory](test) - This directory contains Gradle tests that can be used to verify a deployment. It also has Ansible playbooks for creating infrastructure, provisioning software and testing with Gradle.
## Getting Started
## Getting Started
1. Install this collection from Ansible Galaxy. This collection is also available in RedHat Automation Hub.
@@ -29,9 +22,9 @@ This Ansible directory consists of the following directories that support the JF
2. Ansible uses SSH to connect to hosts. Ensure that your SSH private key is on your client and the public keys are installed on your Ansible hosts.
3. Create your inventory file. Use one of the examples from the [examples directory](examples) to construct an inventory file (hosts.yml) with the host addresses and variables.
3. Create your inventory file. Use one of the examples from the [examples directory](https://github.com/jfrog/JFrog-Cloud-Installers/tree/master/Ansible/examples) to construct an inventory file (hosts.yml) with the host addresses and variables.
4. Create your playbook. Use one of the examples from the [examples directory](examples) to construct a playbook using the JFrog Ansible roles. These roles will be applied to your inventory and provision software.
4. Create your playbook. Use one of the examples from the [examples directory](https://github.com/jfrog/JFrog-Cloud-Installers/tree/master/Ansible/examples) to construct a playbook using the JFrog Ansible roles. These roles will be applied to your inventory and provision software.
5. Then execute with the following command to provision the JFrog software with Ansible. Variables can also be passed in at the command-line.
@@ -74,4 +67,23 @@ ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -A us
eg.
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -A ubuntu@{{ azureDeployment.deployment.outputs.lbIp.value }} -W %h:%p"'
```
## Upgrades
The Artifactory and Xray roles support software upgrades. To use a role to perform a software upgrade only, use the _artifactory_upgrade_only_ or _xray_upgrade_only_ variables and specify the version. See the following example.
```
- hosts: artifactory
vars:
artifactory_version: "{{ lookup('env', 'artifactory_version_upgrade') }}"
artifactory_upgrade_only: true
roles:
- artifactory
- hosts: xray
vars:
xray_version: "{{ lookup('env', 'xray_version_upgrade') }}"
xray_upgrade_only: true
roles:
- xray
```

View File

@@ -9,7 +9,7 @@ namespace: "jfrog"
name: "installers"
# The version of the collection. Must be compatible with semantic versioning
version: "1.0.7"
version: "1.0.8"
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: "README.md"

View File

@@ -14,6 +14,7 @@ The artifactory role installs the Artifactory Pro software onto the host. Per th
* _server_name_: This is the server name. eg. "artifactory.54.175.51.178.xip.io"
* _system_file_: Your own [system YAML](https://www.jfrog.com/confluence/display/JFROG/System+YAML+Configuration+File) file can be specified and used. **If specified, this file will be used rather than constructing a file from the parameters above.**
* _binary_store_file_: Your own [binary store file](https://www.jfrog.com/confluence/display/JFROG/Configuring+the+Filestore) can be used. If specified, the default cluster-file-system will not be used.
* _artifactory_upgrade_only_: Perform an software upgrade only. Default is false.
### primary vars (vars used by the primary Artifactory server)
* _artifactory_is_primary_: For the primary node this must be set to **true**.
@@ -29,4 +30,16 @@ The artifactory role installs the Artifactory Pro software onto the host. Per th
- hosts: primary
roles:
- artifactory
```
## Upgrades
The Artifactory role supports software upgrades. To use a role to perform a software upgrade only, use the _artifactory_upgrade_only_ variable and specify the version. See the following example.
```
- hosts: artifactory
vars:
artifactory_version: "{{ lookup('env', 'artifactory_version_upgrade') }}"
artifactory_upgrade_only: true
roles:
- artifactory
```

View File

@@ -20,7 +20,7 @@ artifactory_ha_enabled: true
artifactory_is_primary: true
# The location where Artifactory should install.
artifactory_download_directory: /opt/jfrog
jfrog_home_directory: /opt/jfrog
# The location where Artifactory should store data.
artifactory_file_store_dir: /data
@@ -31,7 +31,8 @@ artifactory_flavour: pro
extra_java_opts: -server -Xms2g -Xmx14g -Xss256k -XX:+UseG1GC
artifactory_tar: https://dl.bintray.com/jfrog/artifactory-pro/org/artifactory/pro/jfrog-artifactory-pro/{{ artifactory_version }}/jfrog-artifactory-pro-{{ artifactory_version }}-linux.tar.gz
artifactory_home: "{{ artifactory_download_directory }}/artifactory-{{ artifactory_flavour }}-{{ artifactory_version }}"
artifactory_home: "{{ jfrog_home_directory }}/artifactory"
artifactory_untar_home: "{{ jfrog_home_directory }}/artifactory-{{ artifactory_flavour }}-{{ artifactory_version }}"
artifactory_user: artifactory
artifactory_group: artifactory
@@ -46,3 +47,6 @@ service_list:
status_pattern: artifactory
user_name: "{{ artifactory_user }}"
group_name: "{{ artifactory_group }}"
# if this is an upgrade
artifactory_upgrade_only: false

View File

@@ -0,0 +1,166 @@
---
- debug:
msg: "Performing installation of Artifactory..."
- name: install nginx
include_role:
name: artifactory_nginx
- name: create group for artifactory
group:
name: "{{ artifactory_group }}"
state: present
become: yes
- name: create user for artifactory
user:
name: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
system: yes
become: yes
- name: ensure jfrog_home_directory exists
file:
path: "{{ jfrog_home_directory }}"
state: directory
become: yes
- name: download artifactory
unarchive:
src: "{{ artifactory_tar }}"
dest: "{{ jfrog_home_directory }}"
remote_src: yes
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
creates: "{{ artifactory_untar_home }}"
become: yes
register: downloadartifactory
until: downloadartifactory is succeeded
retries: 3
- name: MV untar directory to artifactory home
command: "mv {{ artifactory_untar_home }} {{ artifactory_home }}"
become: yes
- name: ensure artifactory_file_store_dir exists
file:
path: "{{ artifactory_file_store_dir }}"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: ensure etc exists
file:
path: "{{ artifactory_home }}/var/etc"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: use specified system yaml
copy:
src: "{{ system_file }}"
dest: "{{ artifactory_home }}/var/etc/system.yaml"
become: yes
when: system_file is defined
- name: configure system yaml
template:
src: system.yaml.j2
dest: "{{ artifactory_home }}/var/etc/system.yaml"
become: yes
when: system_file is not defined
- name: ensure {{ artifactory_home }}/var/etc/security/ exists
file:
path: "{{ artifactory_home }}/var/etc/security/"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: configure master key
template:
src: master.key.j2
dest: "{{ artifactory_home }}/var/etc/security/master.key"
become: yes
- name: configure join key
template:
src: join.key.j2
dest: "{{ artifactory_home }}/var/etc/security/join.key"
become: yes
- name: ensure {{ artifactory_home }}/var/etc/artifactory/info/ exists
file:
path: "{{ artifactory_home }}/var/etc/artifactory/info/"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: configure installer info
template:
src: installer-info.json.j2
dest: "{{ artifactory_home }}/var/etc/artifactory/info/installer-info.json"
become: yes
- name: use specified binary store
copy:
src: "{{ binary_store_file }}"
dest: "{{ artifactory_home }}/var/etc/binarystore.xml"
become: yes
when: binary_store_file is defined
- name: use default binary store
template:
src: binarystore.xml.j2
dest: "{{ artifactory_home }}/var/etc/binarystore.xml"
become: yes
when: binary_store_file is not defined
- name: use license file
copy:
src: "{{ artifactory_license_file }}"
dest: "{{ artifactory_home }}/var/etc/artifactory/artifactory.cluster.license"
become: yes
when: artifactory_license_file is defined and artifactory_is_primary == true
- name: use license strings
template:
src: artifactory.cluster.license.j2
dest: "{{ artifactory_home }}/var/etc/artifactory/artifactory.cluster.license"
become: yes
when: artifactory_license_file is not defined and artifactory_is_primary == true
- name: download database driver
get_url:
url: "{{ db_download_url }}"
dest: "{{ artifactory_home }}/var/bootstrap/artifactory/tomcat/lib"
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: create artifactory service
shell: "{{ artifactory_home }}/app/bin/installService.sh"
become: yes
- name: start and enable the primary node
service:
name: artifactory
state: restarted
become: yes
when: artifactory_is_primary == true
- name: random wait before restarting to prevent secondary nodes from hitting DB first
pause:
seconds: "{{ 120 | random + 10}}"
when: artifactory_is_primary == false
- name: start and enable the secondary nodes
service:
name: artifactory
state: restarted
become: yes
when: artifactory_is_primary == false

View File

@@ -1,160 +1,6 @@
---
# tasks file for artifactory
- name: install nginx
include_role:
name: artifactory_nginx
- name: create group for artifactory
group:
name: "{{ artifactory_group }}"
state: present
become: yes
- name: create user for artifactory
user:
name: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
system: yes
become: yes
- name: ensure artifactory_download_directory exists
file:
path: "{{ artifactory_download_directory }}"
state: directory
become: yes
- name: download artifactory
unarchive:
src: "{{ artifactory_tar }}"
dest: "{{ artifactory_download_directory }}"
remote_src: yes
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
creates: "{{ artifactory_home }}"
become: yes
register: downloadartifactory
until: downloadartifactory is succeeded
retries: 3
- name: ensure artifactory_file_store_dir exists
file:
path: "{{ artifactory_file_store_dir }}"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: ensure etc exists
file:
path: "{{ artifactory_home }}/var/etc"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: use specified system yaml
copy:
src: "{{ system_file }}"
dest: "{{ artifactory_home }}/var/etc/system.yaml"
become: yes
when: system_file is defined
- name: configure system yaml
template:
src: system.yaml.j2
dest: "{{ artifactory_home }}/var/etc/system.yaml"
become: yes
when: system_file is not defined
- name: ensure {{ artifactory_home }}/var/etc/security/ exists
file:
path: "{{ artifactory_home }}/var/etc/security/"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: configure master key
template:
src: master.key.j2
dest: "{{ artifactory_home }}/var/etc/security/master.key"
become: yes
- name: configure join key
template:
src: join.key.j2
dest: "{{ artifactory_home }}/var/etc/security/join.key"
become: yes
- name: ensure {{ artifactory_home }}/var/etc/artifactory/info/ exists
file:
path: "{{ artifactory_home }}/var/etc/artifactory/info/"
state: directory
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: configure installer info
template:
src: installer-info.json.j2
dest: "{{ artifactory_home }}/var/etc/artifactory/info/installer-info.json"
become: yes
- name: use specified binary store
copy:
src: "{{ binary_store_file }}"
dest: "{{ artifactory_home }}/var/etc/binarystore.xml"
become: yes
when: binary_store_file is defined
- name: use default binary store
template:
src: binarystore.xml.j2
dest: "{{ artifactory_home }}/var/etc/binarystore.xml"
become: yes
when: binary_store_file is not defined
- name: use license file
copy:
src: "{{ artifactory_license_file }}"
dest: "{{ artifactory_home }}/var/etc/artifactory/artifactory.cluster.license"
become: yes
when: artifactory_license_file is defined and artifactory_is_primary == true
- name: use license strings
template:
src: artifactory.cluster.license.j2
dest: "{{ artifactory_home }}/var/etc/artifactory/artifactory.cluster.license"
become: yes
when: artifactory_license_file is not defined and artifactory_is_primary == true
- name: download database driver
get_url:
url: "{{ db_download_url }}"
dest: "{{ artifactory_home }}/var/bootstrap/artifactory/tomcat/lib"
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
become: yes
- name: create artifactory service
shell: "{{ artifactory_home }}/app/bin/installService.sh"
become: yes
- name: start and enable the primary node
service:
name: artifactory
state: restarted
become: yes
when: artifactory_is_primary == true
- name: random wait before restarting to prevent secondary nodes from hitting DB first
pause:
seconds: "{{ 120 | random + 10}}"
when: artifactory_is_primary == false
- name: start and enable the secondary nodes
service:
name: artifactory
state: restarted
become: yes
when: artifactory_is_primary == false
- name: perform installation
include_tasks: "install.yml"
when: not artifactory_upgrade_only
- name: perform upgrade
include_tasks: "upgrade.yml"
when: artifactory_upgrade_only

View File

@@ -0,0 +1,63 @@
---
- debug:
msg: "Performing upgrade of Artifactory..."
- name: stop artifactory
service:
name: artifactory
state: stopped
become: yes
- name: ensure jfrog_home_directory exists
file:
path: "{{ jfrog_home_directory }}"
state: directory
become: yes
- name: download artifactory
unarchive:
src: "{{ artifactory_tar }}"
dest: "{{ jfrog_home_directory }}"
remote_src: yes
owner: "{{ artifactory_user }}"
group: "{{ artifactory_group }}"
creates: "{{ artifactory_untar_home }}"
become: yes
register: downloadartifactory
until: downloadartifactory is succeeded
retries: 3
- name: Delete artifactory app
file:
path: "{{ artifactory_home }}/app"
state: absent
become: yes
- name: CP new app to artifactory app
command: "cp -r {{ artifactory_untar_home }}/app {{ artifactory_home }}/app"
become: yes
- name: Delete untar directory
file:
path: "{{ artifactory_untar_home }}"
state: absent
become: yes
- name: start and enable the primary node
service:
name: artifactory
state: restarted
become: yes
when: artifactory_is_primary == true
- name: random wait before restarting to prevent secondary nodes from hitting DB first
pause:
seconds: "{{ 120 | random + 10}}"
when: artifactory_is_primary == false
- name: start and enable the secondary nodes
service:
name: artifactory
state: restarted
become: yes
when: artifactory_is_primary == false

View File

@@ -12,6 +12,7 @@ The xray role will install Xray software onto the host. An Artifactory server an
* _db_user_: The database user to configure. eg. "xray"
* _db_password_: The database password to configure. "xray"
* _system_file_: Your own [system YAML](https://www.jfrog.com/confluence/display/JFROG/System+YAML+Configuration+File) file can be specified and used. If specified, this file will be used rather than constructing a file from the parameters above.
* _xray_upgrade_only_: Perform an software upgrade only. Default is false.
## Example Playbook
```
@@ -19,4 +20,16 @@ The xray role will install Xray software onto the host. An Artifactory server an
- hosts: xray
roles:
- xray
```
## Upgrades
The Xray role supports software upgrades. To use a role to perform a software upgrade only, use the _xray_upgrade_only_ variables and specify the version. See the following example.
```
- hosts: xray
vars:
xray_version: "{{ lookup('env', 'xray_version_upgrade') }}"
xray_upgrade_only: true
roles:
- xray
```

View File

@@ -10,14 +10,18 @@ xray_version: 3.5.2
xray_ha_enabled: true
# The location where xray should install.
xray_download_directory: /opt/jfrog
jfrog_home_directory: /opt/jfrog
# The remote xray download file
xray_tar: https://bintray.com/standAloneDownload/downloadArtifact?agree=true&artifactPath=/jfrog/jfrog-xray/xray-linux/{{ xray_version }}/jfrog-xray-{{ xray_version }}-linux.tar.gz&callback_id=anonymous&product=xray
xray_tar: https://dl.bintray.com/jfrog/jfrog-xray/xray-linux/{{ xray_version }}/jfrog-xray-{{ xray_version }}-linux.tar.gz
#The xray install directory
xray_home: "{{ xray_download_directory }}/jfrog-xray-{{ xray_version }}-linux"
xray_untar_home: "{{ jfrog_home_directory }}/jfrog-xray-{{ xray_version }}-linux"
xray_home: "{{ jfrog_home_directory }}/xray"
#xray users and groups
xray_user: xray
xray_group: xray
# if this is an upgrade
xray_upgrade_only: false

View File

@@ -0,0 +1,103 @@
---
- debug:
msg: "Performing installation of Xray..."
- name: create group for xray
group:
name: "{{ xray_group }}"
state: present
become: yes
- name: create user for xray
user:
name: "{{ xray_user }}"
group: "{{ xray_group }}"
system: yes
become: yes
- name: ensure jfrog_home_directory exists
file:
path: "{{ jfrog_home_directory }}"
state: directory
become: yes
- name: download xray
unarchive:
src: "{{ xray_tar }}"
dest: "{{ jfrog_home_directory }}"
remote_src: yes
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
creates: "{{ xray_untar_home }}"
become: yes
register: downloadxray
until: downloadxray is succeeded
retries: 3
- name: MV untar directory to xray home
command: "mv {{ xray_untar_home }} {{ xray_home }}"
become: yes
- debug:
msg: "Running dependency installation for {{ ansible_os_family }}"
- name: perform dependency installation
include_tasks: "{{ ansible_os_family }}.yml"
- name: ensure etc exists
file:
path: "{{ xray_home }}/var/etc"
state: directory
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
become: yes
- name: configure system yaml
template:
src: system.yaml.j2
dest: "{{ xray_home }}/var/etc/system.yaml"
become: yes
- name: ensure {{ xray_home }}/var/etc/security/ exists
file:
path: "{{ xray_home }}/var/etc/security/"
state: directory
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
become: yes
- name: configure master key
template:
src: master.key.j2
dest: "{{ xray_home }}/var/etc/security/master.key"
become: yes
- name: configure join key
template:
src: join.key.j2
dest: "{{ xray_home }}/var/etc/security/join.key"
become: yes
- name: ensure {{ xray_home }}/var/etc/info/ exists
file:
path: "{{ xray_home }}/var/etc/info/"
state: directory
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
become: yes
- name: configure installer info
template:
src: installer-info.json.j2
dest: "{{ xray_home }}/var/etc/info/installer-info.json"
become: yes
- name: create xray service
shell: "{{ xray_home }}/app/bin/installService.sh"
become: yes
- name: start and enable xray
service:
name: xray
state: restarted
become: yes

View File

@@ -1,96 +1,6 @@
---
- name: create group for xray
group:
name: "{{ xray_group }}"
state: present
become: yes
- name: create user for xray
user:
name: "{{ xray_user }}"
group: "{{ xray_group }}"
system: yes
become: yes
- name: ensure xray_download_directory exists
file:
path: "{{ xray_download_directory }}"
state: directory
become: yes
- name: download xray
unarchive:
src: "{{ xray_tar }}"
dest: "{{ xray_download_directory }}"
remote_src: yes
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
creates: "{{ xray_home }}"
become: yes
register: downloadxray
until: downloadxray is succeeded
retries: 3
- debug:
msg: "Running dependency installation for {{ ansible_os_family }}"
- name: perform dependency installation
include_tasks: "{{ ansible_os_family }}.yml"
- name: ensure etc exists
file:
path: "{{ xray_home }}/var/etc"
state: directory
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
become: yes
- name: configure system yaml
template:
src: system.yaml.j2
dest: "{{ xray_home }}/var/etc/system.yaml"
become: yes
- name: ensure {{ xray_home }}/var/etc/security/ exists
file:
path: "{{ xray_home }}/var/etc/security/"
state: directory
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
become: yes
- name: configure master key
template:
src: master.key.j2
dest: "{{ xray_home }}/var/etc/security/master.key"
become: yes
- name: configure join key
template:
src: join.key.j2
dest: "{{ xray_home }}/var/etc/security/join.key"
become: yes
- name: ensure {{ xray_home }}/var/etc/info/ exists
file:
path: "{{ xray_home }}/var/etc/info/"
state: directory
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
become: yes
- name: configure installer info
template:
src: installer-info.json.j2
dest: "{{ xray_home }}/var/etc/info/installer-info.json"
become: yes
- name: create xray service
shell: "{{ xray_home }}/app/bin/installService.sh"
become: yes
- name: start and enable xray
service:
name: xray
state: restarted
become: yes
- name: perform installation
include_tasks: "install.yml"
when: not xray_upgrade_only
- name: perform upgrade
include_tasks: "upgrade.yml"
when: xray_upgrade_only

View File

@@ -0,0 +1,54 @@
---
- debug:
msg: "Performing upgrade of Xray..."
- name: stop xray
service:
name: xray
state: stopped
become: yes
- name: ensure jfrog_home_directory exists
file:
path: "{{ jfrog_home_directory }}"
state: directory
become: yes
- name: download xray
unarchive:
src: "{{ xray_tar }}"
dest: "{{ jfrog_home_directory }}"
remote_src: yes
owner: "{{ xray_user }}"
group: "{{ xray_group }}"
creates: "{{ xray_untar_home }}"
become: yes
register: downloadxray
until: downloadxray is succeeded
retries: 3
- name: Delete xray app
file:
path: "{{ xray_home }}/app"
state: absent
become: yes
- name: CP new app to xray app
command: "cp -r {{ xray_untar_home }}/app {{ xray_home }}/app"
become: yes
- name: Delete untar directory
file:
path: "{{ xray_untar_home }}"
state: absent
become: yes
- name: create xray service
shell: "{{ xray_home }}/app/bin/installService.sh"
become: yes
- name: start and enable xray
service:
name: xray
state: restarted
become: yes