asteed closed pull request #3998: Add support for jenkins environment in ansible
URL: https://github.com/apache/incubator-openwhisk/pull/3998
 
 
   

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/.gitignore b/.gitignore
index 426c27382a..cfeda8612a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@ results
 /ansible/environments/*
 !/ansible/environments/distributed
 !/ansible/environments/docker-machine
+!/ansible/environments/jenkins
 !/ansible/environments/local
 !/ansible/environments/mac
 !/ansible/environments/vagrant
diff --git a/ansible/environments/jenkins/group_vars/all 
b/ansible/environments/jenkins/group_vars/all
new file mode 100755
index 0000000000..591cfcdb2a
--- /dev/null
+++ b/ansible/environments/jenkins/group_vars/all
@@ -0,0 +1,39 @@
+whisk_version_name: local
+config_root_dir: /tmp/wskconf
+whisk_logs_dir: /tmp/wsklogs
+coverage_logs_dir: /tmp/wskcov
+docker_registry: ""
+docker_dns: ""
+bypass_pull_for_local_images: true
+
+db_prefix: whisk_local_
+
+# Auto lookup to find the db credentials
+db_provider: "{{ lookup('ini', 'db_provider section=db_creds file={{ 
playbook_dir }}/db_local.ini') }}"
+db_username: "{{ lookup('ini', 'db_username section=db_creds file={{ 
playbook_dir }}/db_local.ini') }}"
+db_password: "{{ lookup('ini', 'db_password section=db_creds file={{ 
playbook_dir }}/db_local.ini') }}"
+db_protocol: "{{ lookup('ini', 'db_protocol section=db_creds file={{ 
playbook_dir }}/db_local.ini') }}"
+db_host: "{{ lookup('ini', 'db_host section=db_creds file={{ playbook_dir 
}}/db_local.ini') }}"
+db_port: "{{ lookup('ini', 'db_port section=db_creds file={{ playbook_dir 
}}/db_local.ini') }}"
+
+# API GW connection configuration
+apigw_auth_user: ""
+apigw_auth_pwd: ""
+apigw_host_v2: "http://{{ groups['apigateway']|first 
}}:{{apigateway.port.api}}/v2"
+
+invoker_allow_multiple_instances: true
+
+# Set kafka configuration
+kafka_heap: '512m'
+kafka_topics_completed_retentionBytes: 104857600
+kafka_topics_completed_retentionMS: 300000
+kafka_topics_health_retentionBytes: 104857600
+kafka_topics_health_retentionMS: 300000
+kafka_topics_invoker_retentionBytes: 104857600
+kafka_topics_invoker_retentionMS: 300000
+
+env_hosts_dir: "{{ playbook_dir }}/environments/jenkins"
+
+logs_dir_become: false
+invoker_dir_become: false
+controller_dir_become: false
\ No newline at end of file
diff --git a/ansible/environments/jenkins/host_vars/ansible 
b/ansible/environments/jenkins/host_vars/ansible
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/ansible/environments/jenkins/hosts.j2.ini 
b/ansible/environments/jenkins/hosts.j2.ini
new file mode 100644
index 0000000000..04c4b19b3e
--- /dev/null
+++ b/ansible/environments/jenkins/hosts.j2.ini
@@ -0,0 +1,38 @@
+; the first parameter in a host is the inventory_hostname
+
+; used for local actions only
+ansible ansible_connection=local
+
+[edge]
+{{local_ip_result.stdout}}          ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+
+[controllers]
+controller0         ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+;{% if mode is defined and 'HA' in mode %}
+;controller1         ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+;{% endif %}
+
+[kafkas]
+kafka0              ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+{% if mode is defined and 'HA' in mode %}
+kafka1              ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+{% endif %}
+
+[zookeepers:children]
+kafkas
+
+[invokers]
+invoker0            ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+{% if mode is defined and 'HA' in mode %}
+invoker1            ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+{% endif %}
+
+; db group is only used if db_provider is CouchDB
+[db]
+{{local_ip_result.stdout}}           ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+
+[redis]
+{{local_ip_result.stdout}}           ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
+
+[apigateway]
+{{local_ip_result.stdout}}           ansible_host={{local_ip_result.stdout}}  
ansible_connection=local
diff --git a/ansible/roles/invoker/tasks/deploy.yml 
b/ansible/roles/invoker/tasks/deploy.yml
index 706d5dcf7e..f8447233d1 100644
--- a/ansible/roles/invoker/tasks/deploy.yml
+++ b/ansible/roles/invoker/tasks/deploy.yml
@@ -56,7 +56,7 @@
   when: environmentInformation.type == "docker-machine"
 
 - name: "determine docker root dir"
-  shell: echo -e "GET http:/v1.24/info HTTP/1.0\r\n" | nc -U 
/var/run/docker.sock | grep "{"
+  shell: echo -e "GET http://{{ ansible_host }}:{{ docker.port }}/v1.24/info 
HTTP/1.0\r\n" | nc -U /var/run/docker.sock | grep "{"
   args:
     executable: /bin/bash
   register: dockerInfo_output
@@ -107,7 +107,7 @@
 
 - name: "get invoker info"
   shell: |
-    INFO=`echo -e "GET http:/v1.24/containers/json?filters={{ '{"name":[ 
"invoker" ],"ancestor":[ "invoker" ]}' | urlencode }} HTTP/1.0\r\n" | nc -U 
/var/run/docker.sock | grep "{"`
+    INFO=`echo -e "GET http://{{ ansible_host }}:{{ docker.port 
}}/v1.24/containers/json?filters={{ '{"name":[ "invoker" ],"ancestor":[ 
"invoker" ]}' | urlencode }} HTTP/1.0\r\n" | nc -U /var/run/docker.sock | grep 
"{"`
     if [ -z "$INFO" ]; then
       echo []
     else
diff --git a/ansible/setup.yml b/ansible/setup.yml
index b6a43cd1ad..7effd0a454 100644
--- a/ansible/setup.yml
+++ b/ansible/setup.yml
@@ -9,6 +9,15 @@
     local_action: template 
src="{{playbook_dir}}/environments/local/hosts.j2.ini" dest="{{ playbook_dir 
}}/environments/local/hosts"
     when: "'environments/local' in hosts_dir"
 
+  - name: detect local public IP
+    local_action: shell ip a | grep "scope global $(ip route | grep default | 
cut -d ' ' -f 5)" | grep -Po '(?<=inet )[\d.]+'
+    register: local_ip_result
+    when: "'environments/jenkins' in hosts_dir"
+
+  - name: gen hosts if 'jenkins' env is used
+    local_action: template 
src="{{playbook_dir}}/environments/jenkins/hosts.j2.ini" dest="{{ playbook_dir 
}}/environments/jenkins/hosts"
+    when: "'environments/jenkins' in hosts_dir"
+
   - name: find the ip of docker-machine
     local_action: shell "docker-machine" "ip" "{{docker_machine_name | 
default('whisk')}}"
     register: result


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to