Skip to content

Commit

Permalink
Add zun-wsproxy into kolla-ansible
Browse files Browse the repository at this point in the history
the zun-wsproxy image is exists in kolla[0], but kolla-ansible
missing, this ps to add it.

[0]: https://github.com/openstack/kolla/tree/master/docker/zun/zun-wsproxy
Co-Authored-By: ZhijunWei <wzj334965317@outlook.com>

Change-Id: I89ef3463dfa5df8cf2d963ff0f0c7ddc382fc79b
Closes-Bug: #1765728
  • Loading branch information
caoyuan authored and weizj committed Jun 27, 2018
1 parent 12d8ba0 commit 1b2bb2e
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 4 deletions.
1 change: 1 addition & 0 deletions ansible/group_vars/all.yml
Expand Up @@ -322,6 +322,7 @@ zookeeper_peer_port: "2888"
zookeeper_quorum_port: "3888"

zun_api_port: "9517"
zun_wsproxy_port: "6784"

opendaylight_clustering_port: "2550"
opendaylight_restconf_port: "8087"
Expand Down
3 changes: 3 additions & 0 deletions ansible/inventory/all-in-one
Expand Up @@ -618,6 +618,9 @@ placement
[zun-api:children]
zun

[zun-wsproxy:children]
zun

[zun-compute:children]
compute

Expand Down
3 changes: 3 additions & 0 deletions ansible/inventory/multinode
Expand Up @@ -637,6 +637,9 @@ placement
[zun-api:children]
zun

[zun-wsproxy:children]
zun

[zun-compute:children]
compute

Expand Down
18 changes: 18 additions & 0 deletions ansible/roles/haproxy/templates/haproxy.cfg.j2
Expand Up @@ -1194,6 +1194,13 @@ listen zun_api
{% for host in groups['zun-api'] %}
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ zun_api_port }} check inter 2000 rise 2 fall 5
{% endfor %}

listen zun_wsproxy
bind {{ kolla_internal_vip_address }}:{{ zun_wsproxy_port }}
http-request del-header X-Forwarded-Proto if { ssl_fc }
{% for host in groups['zun-wsproxy'] %}
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ zun_wsproxy_port }} check inter 2000 rise 2 fall 5
{% endfor %}
{% if haproxy_enable_external_vip | bool %}

listen zun_api_external
Expand All @@ -1206,6 +1213,17 @@ listen zun_api_external
{% for host in groups['zun-api'] %}
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ zun_api_port }} check inter 2000 rise 2 fall 5
{% endfor %}

listen zun_wsproxy_external
bind {{ kolla_external_vip_address }}:{{ zun_wsproxy_port }} {{ tls_bind_info }}
http-request del-header X-Forwarded-Proto
http-request set-header X-Forwarded-Proto https if { ssl_fc }
{% for http_option in haproxy_listen_http_extra %}
{{ http_option }}
{% endfor %}
{% for host in groups['zun-wsproxy'] %}
server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ zun_wsproxy_port }} check inter 2000 rise 2 fall 5
{% endfor %}
{% endif %}
{% endif %}

Expand Down
22 changes: 18 additions & 4 deletions ansible/roles/zun/defaults/main.yml
Expand Up @@ -12,6 +12,16 @@ zun_services:
- "/etc/localtime:/etc/localtime:ro"
- "{{ kolla_dev_repos_directory ~ '/zun/zun:/var/lib/kolla/venv/lib/python2.7/site-packages/zun' if zun_dev_mode | bool else '' }}"
- "kolla_logs:/var/log/kolla/"
zun-wsproxy:
container_name: zun_wsproxy
group: zun-wsproxy
enabled: true
image: "{{ zun_wsproxy_image_full }}"
volumes:
- "{{ node_config_directory }}/zun-wsproxy/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "{{ kolla_dev_repos_directory ~ '/zun/zun:/var/lib/kolla/venv/lib/python2.7/site-packages/zun' if zun_dev_mode | bool else '' }}"
- "kolla_logs:/var/log/kolla/"
zun-compute:
container_name: zun_compute
group: zun-compute
Expand Down Expand Up @@ -40,14 +50,18 @@ zun_database_address: "{{ database_address }}:{{ database_port }}"
zun_install_type: "{{ kolla_install_type }}"
zun_tag: "{{ openstack_release }}"

zun_compute_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ zun_install_type }}-zun-compute"
zun_compute_tag: "{{ zun_tag }}"
zun_compute_image_full: "{{ zun_compute_image }}:{{ zun_compute_tag }}"

zun_api_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ zun_install_type }}-zun-api"
zun_api_tag: "{{ zun_tag }}"
zun_api_image_full: "{{ zun_api_image }}:{{ zun_api_tag }}"

zun_wsproxy_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ zun_install_type }}-zun-wsproxy"
zun_wsproxy_tag: "{{ zun_tag }}"
zun_wsproxy_image_full: "{{ zun_wsproxy_image }}:{{ zun_wsproxy_tag }}"

zun_compute_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ zun_install_type }}-zun-compute"
zun_compute_tag: "{{ zun_tag }}"
zun_compute_image_full: "{{ zun_compute_image }}:{{ zun_compute_tag }}"


####################
## OpenStack
Expand Down
24 changes: 24 additions & 0 deletions ansible/roles/zun/handlers/main.yml
Expand Up @@ -25,6 +25,30 @@
or policy_overwriting.changed | bool
or zun_api_container.changed | bool

- name: Restart zun-wsproxy container
vars:
service_name: "zun-wsproxy"
service: "{{ zun_services[service_name] }}"
config_json: "{{ zun_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
zun_conf: "{{ zun_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_overwriting: "{{ zun_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}"
zun_wsproxy_container: "{{ check_zun_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
privileged: "{{ service.privileged | default(False) }}"
volumes: "{{ service.volumes|reject('equalto', '')|list }}"
when:
- kolla_action != "config"
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or zun_conf.changed | bool
or policy_overwriting.changed | bool
or zun_wsproxy_container.changed | bool

- name: Restart zun-compute container
vars:
service_name: "zun-compute"
Expand Down
12 changes: 12 additions & 0 deletions ansible/roles/zun/tasks/precheck.yml
Expand Up @@ -3,6 +3,7 @@
kolla_container_facts:
name:
- zun_api
- zun_wsproxy
register: container_facts

- name: Checking free port for Zun API
Expand All @@ -15,3 +16,14 @@
when:
- container_facts['zun_api'] is not defined
- inventory_hostname in groups['zun-api']

- name: Checking free port for Zun WSproxy
wait_for:
host: "{{ api_interface_address }}"
port: "{{ zun_wsproxy_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['zun_wsproxy'] is not defined
- inventory_hostname in groups['zun-wsproxy']
24 changes: 24 additions & 0 deletions ansible/roles/zun/templates/zun-wsproxy.json.j2
@@ -0,0 +1,24 @@
{
"command": "zun-wsproxy --config-file /etc/zun/zun.conf",
"config_files": [
{
"source": "{{ container_config_directory }}/zun.conf",
"dest": "/etc/zun/zun.conf",
"owner": "zun",
"perm": "0600"
}{% if zun_policy_file is defined %},
{
"source": "{{ container_config_directory }}/{{ zun_policy_file }}",
"dest": "/etc/zun/{{ zun_policy_file }}",
"owner": "zun",
"perm": "0600"
}{% endif %}
],
"permissions": [
{
"path": "/var/log/kolla/zun",
"owner": "zun:kolla",
"recurse": true
}
]
}
5 changes: 5 additions & 0 deletions ansible/roles/zun/templates/zun.conf.j2
Expand Up @@ -104,3 +104,8 @@ lock_path = /var/lib/zun/tmp
[oslo_policy]
policy_file = {{ zun_policy_file }}
{% endif %}

[websocket_proxy]
wsproxy_host = {{ api_interface_address }}
wsproxy_port = {{ zun_wsproxy_port }}
base_url = ws://{{ kolla_external_fqdn }}:{{ zun_wsproxy_port }}

0 comments on commit 1b2bb2e

Please sign in to comment.