openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject [incubator-openwhisk] branch master updated: Cli ansible fix (#3334)
Date Mon, 26 Feb 2018 02:50:58 GMT
This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 347d4b7  Cli ansible fix (#3334)
347d4b7 is described below

commit 347d4b72116fcde7fb2988f550220daba28c0959
Author: Jonathan Springer <jonpspri@gmail.com>
AuthorDate: Sun Feb 25 21:50:56 2018 -0500

    Cli ansible fix (#3334)
---
 ansible/group_vars/all                             |  9 ++++----
 .../roles/cli/tasks/copy_local_openwhisk_cli.yml   | 25 +++++++++++++++++++---
 ansible/roles/cli/tasks/deploy.yml                 |  3 ++-
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 8356733..ce20543 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -1,7 +1,7 @@
 mode: deploy
 prompt_user: true
-openwhisk_home: "{{ lookup('env', 'OPENWHISK_HOME')|default(playbook_dir + '/..', true) }}"
-openwhisk_cli_home: "{{ lookup('env', 'OPENWHISK_CLI') | default(openwhisk_home, true) }}"
+openwhisk_home: "{{ lookup('env', 'OPENWHISK_HOME') | default(playbook_dir + '/..', true)
}}"
+openwhisk_cli_home: "{{ lookup('env', 'OPENWHISK_CLI') | default(openwhisk_home ~ '/../incubator-openwhisk-cli',
true) }}"
 exclude_logs_from: []
 
 # This whisk_api_localhost_name_default is used to configure nginx to permit vanity URLs
for web actions
@@ -269,12 +269,11 @@ openwhisk_cli_tag: "{{ lookup('ini', 'git_tag section=openwhisk-cli
file={{ open
 #
 # The location specifies the official website where Openwhisk CLI is hosted in
 # remote mode or location to save the binaries of the OpenWhisk CLI in local mode.
-#
 
 openwhisk_cli:
-  installation_mode: "{{ cli_installation_mode | default('remote') }}"
+  installation_mode: "{{ cli_installation_mode | default(lookup('env', 'OPENWHISK_CLI_MODE'))
| default('remote', true) }}"
   local:
-    location: "{{ openwhisk_cli_home }}/bin"
+    location: "{{ openwhisk_cli_home }}/build"
   remote:
     name: OpenWhisk_CLI
     dest_name: OpenWhisk_CLI
diff --git a/ansible/roles/cli/tasks/copy_local_openwhisk_cli.yml b/ansible/roles/cli/tasks/copy_local_openwhisk_cli.yml
index 50bce81..ac7d234 100644
--- a/ansible/roles/cli/tasks/copy_local_openwhisk_cli.yml
+++ b/ansible/roles/cli/tasks/copy_local_openwhisk_cli.yml
@@ -2,16 +2,35 @@
 
 # Copy the cli binaries to Nginx directory
 
-- local_action: stat path={{ openwhisk_cli.local.location }}/{{ item }}
+- name: "construct local file from which to source"
+  set_fact:
+    source_file: "{{ openwhisk_cli.local.location }}/\
+      {{ item | join('-') | replace('mac','darwin') }}/\
+      {{ (item[0] == 'windows') | ternary ('wsk.exe', 'wsk') }}"
+    target_dir: "{{ cli.nginxdir }}/{{ item[0] }}/{{ item[1] }}"
+    system_match: "{{ ( \
+        (ansible_system == 'Linux' and item[0] == 'linux') \
+        or (ansible_system == 'Darwin' and item[0] == 'mac') \
+        or (ansible_system == 'Windows' and item[0] == 'windows') \
+        ) }}"
+    arch_match: "{{ ( ((ansible_machine=='x86_64')|ternary('amd64', ansible_machine)) ==
item[1] ) }}"
+
+- local_action: stat path={{ source_file }}
   register: binary_path
 
 - name: "ensure Nginx cli directory is writable"
   file:
-    path: "{{ cli.nginxdir }}"
+    path: "{{ target_dir }}"
     state: directory
     mode: 0777
   become: "{{ cli.dir.become }}"
 
 - name: "copy the local binaries from a local directory to Nginx directory"
-  copy: src={{ openwhisk_cli.local.location }}/{{ item }} dest={{ cli.nginxdir }}/
+  copy:
+    src: "{{ source_file }}"
+    dest: "{{ target_dir }}/"
   when: binary_path.stat.exists
+
+- name: "copy the local binary to the root bin directory when architectures match"
+  local_action: copy src={{ source_file }} dest={{ openwhisk_home }}/bin
+  when: system_match and arch_match
diff --git a/ansible/roles/cli/tasks/deploy.yml b/ansible/roles/cli/tasks/deploy.yml
index dc2d1dc..20f6221 100644
--- a/ansible/roles/cli/tasks/deploy.yml
+++ b/ansible/roles/cli/tasks/deploy.yml
@@ -19,7 +19,8 @@
 - name: "copy the binaries from a local directory to Nginx directory"
   include: copy_local_openwhisk_cli.yml
   when: cli_installation_mode == "local"
-  with_items: "{{ cli_os_arch | first | unique }}"
+  with_items:
+    - "{{ cli_os_arch }}"
 
 - name: "copy the local content.json from a local directory to Nginx directory"
   copy: src={{ openwhisk_cli.local.location }}/content.json dest={{ cli.nginxdir }}/

-- 
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.

Mime
View raw message