blob: 914c5b6b8f84f2b0a71ff4723904a67a6620a834 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.
---
# Tasks for handling CLI customization and publishing
#
# Note: The configuration directory is actually located on the local machine;
# this script is run under the local host, usually 172.17.0.1 (docker local)
- name: "Ensure nginx directory for cli exists"
file:
path: "{{ openwhisk_cli.nginxdir.name }}"
state: directory
become: "{{ openwhisk_cli.nginxdir.become }}"
- name: "Ensure temporary directory exists"
file:
path: "{{ nginx.confdir }}/cli_temp/{{ openwhisk_cli.archive_name }}"
state: directory
- name: "Download release archive to build directory ..."
get_url:
url: "{{ openwhisk_cli.remote.location }}/{{ openwhisk_cli.archive_name}}-{{ openwhisk_cli_tag }}-all.tgz"
dest: "{{ nginx.confdir }}/cli_temp/{{ openwhisk_cli.archive_name }}.tgz"
headers: "{{ openwhisk_cli.remote.headers | default('') }}"
when: openwhisk_cli.installation_mode == "remote"
- name: "... or Copy release archive to build directory"
copy:
src: "{{ openwhisk_cli_home }}/release/{{ openwhisk_cli.archive_name}}-{{ openwhisk_cli_tag }}-all.tgz"
dest: "{{ nginx.confdir }}/cli_temp/{{ openwhisk_cli.archive_name }}.tgz"
when: openwhisk_cli.installation_mode == "local"
#
# I really wanted to use 'unarchive' here, but it was quite buggy and didn't
# want to cooperate, so we do a good old-fashioned tar x instead
#
- name: "Expand the archive into the build directory"
shell: >
tar zxf {{ nginx.confdir }}/cli_temp/{{ openwhisk_cli.archive_name }}.tgz
-C {{ nginx.confdir }}/cli_temp/{{ openwhisk_cli.archive_name }}/
# Remote copy does not support recursive copy of directories. That's why I'm using the shell.
- name: "Copy expanded archive to final configuration directory"
# WARNING: The trailing slash is significant, signalling to copy contents
shell: "cp -r {{ nginx.confdir }}/cli_temp/{{ openwhisk_cli.archive_name }}/* {{ openwhisk_cli.nginxdir.name }}"
- name: "Delete temp directory"
file:
path: "{{ nginx.confdir }}/cli_temp"
state: absent
force: yes
- name: "Generate a list of individual tarballs to expand"
find:
paths: "{{ openwhisk_cli.nginxdir.name }}"
patterns: '*.tgz'
recurse: true
register: individual_tarballs
- name: "Unarchive the individual tarballs"
shell: tar zxf {{ item.path }} -C {{ item.path | dirname }}
with_items: "{{ individual_tarballs.files }}"
- name: "Generate a list of individual zipfiles to expand"
find:
paths: "{{ openwhisk_cli.nginxdir.name }}"
patterns: '*.zip'
recurse: true
register: individual_zipfiles
# Use old good unzip instead of unarchive due to a known issue on MacOS
# https://github.com/ansible/ansible-modules-core/issues/3952
- name: "Unarchive the individual zipfiles into binaries"
shell: unzip -o {{ item.path }} -d {{ item.path | dirname }}
with_items: "{{ individual_zipfiles.files }}"