You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/26 02:50:57 UTC

[GitHub] csantanapr closed pull request #3334: Cli ansible fix

csantanapr closed pull request #3334: Cli ansible fix
URL: https://github.com/apache/incubator-openwhisk/pull/3334
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 83567337e7..ce2054352d 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 50bce81e19..ac7d234b60 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 dc2d1dc12b..20f622148d 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 }}/


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services