Skip to content

Instantly share code, notes, and snippets.

@Storager
Created August 2, 2019 08:34
Show Gist options
  • Select an option

  • Save Storager/867efcd1f1db18a373bdf9f2246f5f8a to your computer and use it in GitHub Desktop.

Select an option

Save Storager/867efcd1f1db18a373bdf9f2246f5f8a to your computer and use it in GitHub Desktop.
Use Ansible 2.7 to run.
---
- name: Update artifactory ZIP distribution
hosts: all
become: false
vars:
target_version: 6.3.2
# target_versions_path: [ 6.3.8, 6.4.3, 6.5.18, 6.6.10, 6.7.7, 6.8.16, 6.9.5, 6.10.7, 6.11.3]
target_directory: /home/vagrant/artifactory
backup_directory: /home/vagrant/backup
temp_directory: /tmp
items_to_delete:
- webapps
- tomcat
- bin
- misc
tasks:
- name: download artifactory
unarchive:
src: "https://jfrog.bintray.com/artifactory-pro/org/artifactory/pro/jfrog-artifactory-pro/{{ target_version }}/jfrog-artifactory-pro-{{ target_version }}.zip"
dest: "{{ temp_directory }}"
remote_src: true
- name: ensure backup folder exists
file:
path: "{{ backup_directory }}"
state: directory
- name: ensure artifactory folder exists
stat:
path: "{{ target_directory }}"
register: target_present
- name: backup files from source
copy:
src: "{{ target_directory }}"
dest: "{{ backup_directory }}"
force: true
remote_src: true
when: target_present.stat.exists
- name: delete from installation
file:
path: "{{ target_directory }}/{{ item }}"
state: absent
with_items: "{{ items_to_delete }}"
- name: restore from new release
copy:
src: "{{ temp_directory }}/artifactory-pro-{{target_version}}/{{ item }}"
dest: "{{ target_directory }}"
remote_src: true
with_items: "{{ items_to_delete }}"
- name: copy server.xml
copy:
src: "{{ backup_directory }}/artifactory/tomcat/conf/server.xml"
dest: "{{ target_directory }}/tomcat/conf/server.xml"
force: true
remote_src: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment