refactored to improve readability and troubleshooting
diff --git a/tasks/install-mirror.yml b/tasks/install-mirror.yml
new file mode 100644
index 0000000..ce8a2ef
--- /dev/null
+++ b/tasks/install-mirror.yml
@@ -0,0 +1,15 @@
+---
+- name: Install bootstrap from local repository for 4.16.01
+ no_log: True
+ shell: "bash {{ archive_folder }}/repos/bootstrap.sh apigeeprotocol='file://' apigeerepobasepath={{ archive_folder }}/repos JAVA_FIX=C"
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ when: opdk_version | version_compare('4.16.01', '==')
+
+- name: Install bootstrap from local repository for greater than 4.16.01
+ no_log: True
+ shell: "bash {{ archive_folder }}/repos/bootstrap_{{ opdk_version }}.sh apigeeprotocol='file://' apigeerepobasepath={{ archive_folder }}/repos JAVA_FIX=C"
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ when: opdk_version | version_compare('4.16.01', '>')
+
diff --git a/tasks/install-online.yml b/tasks/install-online.yml
new file mode 100644
index 0000000..aee5f3d
--- /dev/null
+++ b/tasks/install-online.yml
@@ -0,0 +1,47 @@
+---
+- name: Create installer path
+ file:
+ path: "{{ opdk_installer_path }}"
+ owner: "{{ opdk_user_name }}"
+ group: "{{ opdk_group_name }}"
+
+- include: online/download-bootstrap-with-no-proxy.yml
+ when: http_proxy is not defined and https_proxy is not defined
+
+- include: online/download-bootstrap-with-proxy.yml
+ when: http_proxy is defined and https_proxy is defined
+
+- name: Bootstrap script exists
+ stat:
+ path: '{{ bootstrap_script }}'
+ register: bootstrap_exists
+
+- name: Cache bootstrap script state
+ cache:
+ key: bootstrap_script_exists
+ value: '{{ bootstrap_exists.stat.exists }}'
+
+- name: Fail the playbook if bootstrap fails to install
+ fail:
+ msg: 'Bootstrap installation failed, no point in letting this go further'
+ when: not bootstrap_exists.stat.exists
+
+- name: Yum clean all
+ shell: "yum clean all"
+
+- block:
+ - include: online/install-bootstrap-with-no-proxy.yml
+ when: http_proxy is not defined and https_proxy is not defined
+
+ - include: online/install-bootstrap-with-proxy.yml
+ when: http_proxy is defined and https_proxy is defined
+
+ rescue:
+ - name: Yum failed to update, let's clean yum
+ shell: 'yum clean all'
+
+ - include: online/install-bootstrap-with-no-proxy.yml
+ when: http_proxy is not defined and https_proxy is not defined
+
+ - include: online/install-bootstrap-with-proxy.yml
+ when: http_proxy is defined and https_proxy is defined
diff --git a/tasks/main.yml b/tasks/main.yml
index 36c9556..fa8c1b3 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -8,7 +8,6 @@
group: "{{ opdk_group_name }}"
- block:
-
- name: Find available epel repos
find:
pattern: "epel*"
@@ -25,169 +24,10 @@
when: opdk_version | version_compare('4.17.01', '>=')
-- block:
- - name: Create installer path
- file:
- path: "{{ opdk_installer_path }}"
- owner: "{{ opdk_user_name }}"
- group: "{{ opdk_group_name }}"
-
- - name: Download bootstrap with no proxy use
- no_log: True
- bootstrap:
- dest_dir: '{{ opdk_installer_path }}'
- version: '{{ opdk_version }}'
- url: '{{ apigee_repo_url }}'
- user_name: '{{ apigee_repo_user }}'
- password: '{{ apigee_repo_password }}'
- register: results
- when: http_proxy is not defined and https_proxy is not defined
-
- - name: Download bootstrap with proxy
- no_log: True
- bootstrap:
- dest_dir: '{{ opdk_installer_path }}'
- version: '{{ opdk_version }}'
- url: '{{ apigee_repo_url }}'
- user_name: '{{ apigee_repo_user }}'
- password: '{{ apigee_repo_password }}'
- register: results
- when: http_proxy is defined and https_proxy is defined
- environment:
- http_proxy: "{{ http_proxy }}"
- https_proxy: "{{ https_proxy }}"
-
- - name: Bootstrap script exists
- stat:
- path: '{{ bootstrap_script }}'
- register: bootstrap_exists
-
- - name: Cache bootstrap script state
- cache:
- key: bootstrap_script_exists
- value: '{{ bootstrap_exists.stat.exists }}'
-
- - name: Fail the playbook if bootstrap fails to install
- fail:
- msg: 'Bootstrap installation failed, no point in letting this go further'
- when: not bootstrap_exists.stat.exists
-
- - name: Yum clean all
- shell: "yum clean all"
-
- - block:
- - name: Update apigee-service if upgrade_edge is set as part of an upgrade
- shell: "bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword='{{ apigee_repo_password }}' JAVA_FIX=C"
- env:
- JAVA_HOME: '{{ java_home }}'
- when: upgrade_edge is defined and upgrade_edge | bool == True and http_proxy is not defined and https_proxy is not defined
-
- - name: Install bootstrap from the provided apigee_repo_uri and apigee_repo_protocol with no proxy
- shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
- args:
- creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
- env:
- JAVA_HOME: '{{ java_home }}'
- failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
- when: apigee_stage is not defined
- register: results
- when: http_proxy is not defined and https_proxy is not defined
-
- - name: Install bootstrap from development repositories
- shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeestage={{ apigee_stage }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
- args:
- creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
- env:
- JAVA_HOME: '{{ java_home }}'
- failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
- register: results
- when: apigee_stage is defined and http_proxy is not defined and https_proxy is not defined
-
- - name: Update apigee-service if upgrade_edge is set as part of an upgrade
- shell: "bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword='{{ apigee_repo_password }}' JAVA_FIX=C"
- env:
- JAVA_HOME: '{{ java_home }}'
- when: upgrade_edge is defined and upgrade_edge | bool == True
- environment:
- http_proxy: "{{ http_proxy }}"
- https_proxy: "{{ https_proxy }}"
- when: http_proxy is defined and https_proxy is defined
-
- - name: Install bootstrap from the provided apigee_repo_uri and apigee_repo_protocol with proxy
- shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
- args:
- creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
- env:
- JAVA_HOME: '{{ java_home }}'
- failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
- register: results
- when: apigee_stage is not defined
- environment:
- http_proxy: "{{ http_proxy }}"
- https_proxy: "{{ https_proxy }}"
- when: http_proxy is defined and https_proxy is defined
-
- - name: Install bootstrap from development repositories
- shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeestage={{ apigee_stage }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
- args:
- creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
- env:
- JAVA_HOME: '{{ java_home }}'
- failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
- register: results
- when: apigee_stage is defined
- environment:
- http_proxy: "{{ http_proxy }}"
- https_proxy: "{{ https_proxy }}"
- when: http_proxy is defined and https_proxy is defined
-
- rescue:
- - name: Yum failed to update, let's clean yum
- shell: 'yum clean all'
-
- - name: Update apigee-service if upgrade_edge is set as part of an upgrade
- shell: "bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword='{{ apigee_repo_password }}' JAVA_FIX=C"
- env:
- JAVA_HOME: '{{ java_home }}'
- when: upgrade_edge is defined and upgrade_edge | bool == True
-
- - name: Install bootstrap from the provided apigee_repo_uri and apigee_repo_protocol
- no_log: True
- shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
- args:
- creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
- env:
- JAVA_HOME: '{{ java_home }}'
- failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
- when: apigee_stage is not defined
-
- - name: Install bootstrap from development repositories
- no_log: True
- shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeestage={{ apigee_stage }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
- args:
- creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
- env:
- JAVA_HOME: '{{ java_home }}'
- failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
- when: apigee_stage is defined
-
+- include: install-online.yml
when: archive_folder is not defined
-- block:
- - name: Install bootstrap from local repository for 4.16.01
- no_log: True
- shell: "bash {{ archive_folder }}/repos/bootstrap.sh apigeeprotocol='file://' apigeerepobasepath={{ archive_folder }}/repos JAVA_FIX=C"
- env:
- JAVA_HOME: '{{ java_home }}'
- when: opdk_version | version_compare('4.16.01', '==')
-
- - name: Install bootstrap from local repository for greater than 4.16.01
- no_log: True
- shell: "bash {{ archive_folder }}/repos/bootstrap_{{ opdk_version }}.sh apigeeprotocol='file://' apigeerepobasepath={{ archive_folder }}/repos JAVA_FIX=C"
- env:
- JAVA_HOME: '{{ java_home }}'
- when: opdk_version | version_compare('4.16.01', '>')
-
+- include: install-mirror.yml
when: archive_folder is defined and not archive_folder == ''
- name: Validate that apigee-service exists
diff --git a/tasks/online/download-bootstrap-with-no-proxy.yml b/tasks/online/download-bootstrap-with-no-proxy.yml
new file mode 100644
index 0000000..5743143
--- /dev/null
+++ b/tasks/online/download-bootstrap-with-no-proxy.yml
@@ -0,0 +1,11 @@
+---
+- name: Download bootstrap with no proxy use
+ no_log: True
+ bootstrap:
+ dest_dir: '{{ opdk_installer_path }}'
+ version: '{{ opdk_version }}'
+ url: '{{ apigee_repo_url }}'
+ user_name: '{{ apigee_repo_user }}'
+ password: '{{ apigee_repo_password }}'
+ register: results
+
diff --git a/tasks/online/download-bootstrap-with-proxy.yml b/tasks/online/download-bootstrap-with-proxy.yml
new file mode 100644
index 0000000..65c4b9e
--- /dev/null
+++ b/tasks/online/download-bootstrap-with-proxy.yml
@@ -0,0 +1,13 @@
+---
+- name: Download bootstrap with proxy
+ no_log: True
+ bootstrap:
+ dest_dir: '{{ opdk_installer_path }}'
+ version: '{{ opdk_version }}'
+ url: '{{ apigee_repo_url }}'
+ user_name: '{{ apigee_repo_user }}'
+ password: '{{ apigee_repo_password }}'
+ register: results
+ environment:
+ http_proxy: "{{ http_proxy }}"
+ https_proxy: "{{ https_proxy }}"
diff --git a/tasks/online/install-bootstrap-with-no-proxy.yml b/tasks/online/install-bootstrap-with-no-proxy.yml
new file mode 100644
index 0000000..d82a19b
--- /dev/null
+++ b/tasks/online/install-bootstrap-with-no-proxy.yml
@@ -0,0 +1,26 @@
+---
+- name: Update apigee-service if upgrade_edge is set as part of an upgrade
+ shell: "bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword='{{ apigee_repo_password }}' JAVA_FIX=C"
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ when: upgrade_edge is defined and upgrade_edge | bool == True
+
+- name: Install bootstrap from the provided apigee_repo_uri and apigee_repo_protocol with no proxy
+ shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
+ args:
+ creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
+ when: apigee_stage is not defined
+ register: results
+
+- name: Install bootstrap from development repositories with no proxy
+ shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeestage={{ apigee_stage }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
+ args:
+ creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
+ register: results
+ when: apigee_stage is defined
diff --git a/tasks/online/install-bootstrap-with-proxy.yml b/tasks/online/install-bootstrap-with-proxy.yml
new file mode 100644
index 0000000..e9758f3
--- /dev/null
+++ b/tasks/online/install-bootstrap-with-proxy.yml
@@ -0,0 +1,35 @@
+---
+- name: Update apigee-service if upgrade_edge is set as part of an upgrade with proxy
+ shell: "bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword='{{ apigee_repo_password }}' JAVA_FIX=C"
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ when: upgrade_edge is defined and upgrade_edge | bool == True
+ environment:
+ http_proxy: "{{ http_proxy }}"
+ https_proxy: "{{ https_proxy }}"
+
+- name: Install bootstrap from the provided apigee_repo_uri and apigee_repo_protocol with proxy
+ shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
+ args:
+ creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
+ register: results
+ when: apigee_stage is not defined
+ environment:
+ http_proxy: "{{ http_proxy }}"
+ https_proxy: "{{ https_proxy }}"
+
+- name: Install bootstrap from development repositories with proxy
+ shell: 'bash {{ bootstrap_script }} apigeeuser={{ apigee_repo_user }} apigeepassword={{ apigee_repo_password }} apigeestage={{ apigee_stage }} apigeerepohost={{ apigee_repo_uri }} apigeeprotocol={{ apigee_repo_protocol }}:// JAVA_FIX=C'
+ args:
+ creates: '{{ apigee_installation_home }}/apigee-service/bin/apigee-service'
+ env:
+ JAVA_HOME: '{{ java_home }}'
+ failed_when: results is defined and results.rc is defined and results.rc > 0 or results | failed
+ register: results
+ when: apigee_stage is defined
+ environment:
+ http_proxy: "{{ http_proxy }}"
+ https_proxy: "{{ https_proxy }}"