diff options
author | carey.xu <carey.xuhan@huawei.com> | 2015-09-30 11:26:46 +0800 |
---|---|---|
committer | carey.xu <carey.xuhan@huawei.com> | 2015-10-09 15:03:51 +0800 |
commit | 00aaaac786bcec0d2de7c14c4f3c5a89ba2553f5 (patch) | |
tree | 05b45bee93c88f363cb78d79f9dac26cdf12afe6 | |
parent | 9a95593b0c8cdefb6ad4a3c836b699f42b1f7323 (diff) |
compass4nfv support ceilometer
JIRA: COMPASS-53
Change-Id: Ie8fc0f3f03f1de3c9fcf37778e025175ed391bc5
Signed-off-by: carey.xu <carey.xuhan@huawei.com>
27 files changed, 294 insertions, 21 deletions
diff --git a/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml b/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml index bd1499c9..e0683fa8 100644 --- a/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml +++ b/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml @@ -25,6 +25,7 @@ - glance - neutron-common - neutron-network + - ceilometer-controller # - ext-network - dashboard @@ -35,6 +36,7 @@ - nova-compute - neutron-compute - cinder-volume + - ceilometer-compute - hosts: all remote_user: root diff --git a/deploy/adapters/ansible/roles/ceilometer_compute/handlers/main.yml b/deploy/adapters/ansible/roles/ceilometer_compute/handlers/main.yml new file mode 100644 index 00000000..ee30a5f6 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_compute/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart ceilometer relation service + service: name={{ item }} state=restarted enabled=yes + with_items: ceilometer_services diff --git a/deploy/adapters/ansible/roles/ceilometer_compute/tasks/main.yml b/deploy/adapters/ansible/roles/ceilometer_compute/tasks/main.yml new file mode 100644 index 00000000..4fddd1e6 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_compute/tasks/main.yml @@ -0,0 +1,17 @@ +--- +- include_vars: "{{ ansible_os_family }}.yml" + +- name: install ceilometer packages + action: "{{ ansible_pkg_mgr }} name={{ item }} state=present" + with_items: "{{ ceilometer_packages }}| union(packages_noarch)" + +- name: copy ceilometer configs + template: src={{ item.src}} dest=/opt/os_templates + with_items: "{{ ceilometer_configs_templates }}" + +- name: update ceilometer configs + shell: crudini --merge {{ item.1 }} < /opt/os_templates/{{ item.0.src }} + with_subelements: + - ceilometer_configs_templates + - dest + notify: restart ceilometer relation service diff --git a/deploy/adapters/ansible/roles/ceilometer_compute/templates/ceilometer.j2 b/deploy/adapters/ansible/roles/ceilometer_compute/templates/ceilometer.j2 new file mode 100644 index 00000000..d3ee52ab --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_compute/templates/ceilometer.j2 @@ -0,0 +1,17 @@ +[DEFAULT] +verbose = True +rpc_backend = rabbit +rabbit_host = {{ internal_vip.ip }} +rabbit_password = {{ RABBIT_PASS }} + +[publisher] +metering_secret = {{ metering_secret }} + +[service_credentials] +os_auth_url = http://{{ internal_vip.ip }}:5000/v2.0 +os_username = ceilometer +os_tenant_name = service +os_password = {{ CEILOMETER_PASS }} +os_endpoint_type = internalURL +os_region_name = regionOne + diff --git a/deploy/adapters/ansible/roles/ceilometer_compute/templates/nova.j2 b/deploy/adapters/ansible/roles/ceilometer_compute/templates/nova.j2 new file mode 100644 index 00000000..e7532c85 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_compute/templates/nova.j2 @@ -0,0 +1,5 @@ +[DEFAULT] +instance_usage_audit = True +instance_usage_audit_period = hour +notify_on_state_change = vm_and_task_state +notification_driver = messagingv2 diff --git a/deploy/adapters/ansible/roles/ceilometer_compute/vars/Debian.yml b/deploy/adapters/ansible/roles/ceilometer_compute/vars/Debian.yml new file mode 100644 index 00000000..e767016c --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_compute/vars/Debian.yml @@ -0,0 +1,15 @@ +--- +ceilometer_packages: + - ceilometer-agent-compute + +ceilometer_services: + - ceilometer-agent-compute + - nova-compute + +ceilometer_configs_templates: + - src: ceilometer.j2 + dest: + - /etc/ceilometer/ceilometer.conf + - src: nova.j2 + dest: + - /etc/nova/nova.conf diff --git a/deploy/adapters/ansible/roles/ceilometer_compute/vars/RedHat.yml b/deploy/adapters/ansible/roles/ceilometer_compute/vars/RedHat.yml new file mode 100644 index 00000000..041cf477 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_compute/vars/RedHat.yml @@ -0,0 +1,3 @@ +--- +services: [] +packages: [] diff --git a/deploy/adapters/ansible/roles/ceilometer_compute/vars/main.yml b/deploy/adapters/ansible/roles/ceilometer_compute/vars/main.yml new file mode 100644 index 00000000..bb87da65 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_compute/vars/main.yml @@ -0,0 +1,3 @@ +--- +packages_noarch: [] +metering_secret: 1c5df72079b31fb47747 diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/handlers/main.yml b/deploy/adapters/ansible/roles/ceilometer_controller/handlers/main.yml new file mode 100644 index 00000000..ee30a5f6 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart ceilometer relation service + service: name={{ item }} state=restarted enabled=yes + with_items: ceilometer_services diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/tasks/main.yml b/deploy/adapters/ansible/roles/ceilometer_controller/tasks/main.yml new file mode 100644 index 00000000..4fddd1e6 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/tasks/main.yml @@ -0,0 +1,17 @@ +--- +- include_vars: "{{ ansible_os_family }}.yml" + +- name: install ceilometer packages + action: "{{ ansible_pkg_mgr }} name={{ item }} state=present" + with_items: "{{ ceilometer_packages }}| union(packages_noarch)" + +- name: copy ceilometer configs + template: src={{ item.src}} dest=/opt/os_templates + with_items: "{{ ceilometer_configs_templates }}" + +- name: update ceilometer configs + shell: crudini --merge {{ item.1 }} < /opt/os_templates/{{ item.0.src }} + with_subelements: + - ceilometer_configs_templates + - dest + notify: restart ceilometer relation service diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/templates/ceilometer.j2 b/deploy/adapters/ansible/roles/ceilometer_controller/templates/ceilometer.j2 new file mode 100644 index 00000000..09ca5272 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/templates/ceilometer.j2 @@ -0,0 +1,25 @@ +[DEFAULT] +rpc_backend = rabbit +rabbit_host = {{ internal_vip.ip }} +rabbit_password = {{ RABBIT_PASS }} +auth_strategy = keystone +verbose = True + +[database] +connection = mongodb://ceilometer:{{ CEILOMETER_DBPASS }}@{{ internal_vip.ip }}:27017/ceilometer + +[keystone_authtoken] +auth_uri = http://{{ internal_vip.ip }}:5000/v2.0 +identity_uri = http://{{ internal_vip.ip }}:35357 +admin_tenant_name = service +admin_user = ceilometer +admin_password = {{ CEILOMETER_PASS }} + +[service_credentials] +os_auth_url = http://{{ internal_vip.ip }}:5000/v2.0 +os_username = ceilometer +os_tenant_name = service +os_password = {{ CEILOMETER_PASS }} + +[publisher] +metering_secret = {{ metering_secret }} diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/templates/cinder.j2 b/deploy/adapters/ansible/roles/ceilometer_controller/templates/cinder.j2 new file mode 100644 index 00000000..390bd870 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/templates/cinder.j2 @@ -0,0 +1,3 @@ +[DEFAULT] +control_exchange = cinder +notification_driver = messagingv2 diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/templates/glance.j2 b/deploy/adapters/ansible/roles/ceilometer_controller/templates/glance.j2 new file mode 100644 index 00000000..c34f5d81 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/templates/glance.j2 @@ -0,0 +1,5 @@ +[DEFAULT] +notification_driver = messagingv2 +rpc_backend = rabbit +rabbit_host = {{ internal_vip.ip }} +rabbit_password = {{ RABBIT_PASS }} diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/vars/Debian.yml b/deploy/adapters/ansible/roles/ceilometer_controller/vars/Debian.yml new file mode 100644 index 00000000..8317a3eb --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/vars/Debian.yml @@ -0,0 +1,27 @@ +--- +ceilometer_packages: + - ceilometer-api + - ceilometer-collector + - ceilometer-agent-central + - ceilometer-agent-notification + - ceilometer-alarm-evaluator + - ceilometer-alarm-notifier + - python-ceilometerclient + +ceilometer_services: + - ceilometer-agent-central + - ceilometer-agent-notification + - ceilometer-api + - ceilometer-collector + - ceilometer-alarm-evaluator + - ceilometer-alarm-notifier + +ceilometer_configs_templates: + - src: ceilometer.j2 + dest: /etc/ceilometer/ceilometer.conf + - src: cinder.j2 + dest: /etc/cinder/cinder.conf + - src: glance.j2 + dest: + - /etc/glance/glance-api.conf + - /etc/glance/glance-registry.conf diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/vars/RedHat.yml b/deploy/adapters/ansible/roles/ceilometer_controller/vars/RedHat.yml new file mode 100644 index 00000000..041cf477 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/vars/RedHat.yml @@ -0,0 +1,3 @@ +--- +services: [] +packages: [] diff --git a/deploy/adapters/ansible/roles/ceilometer_controller/vars/main.yml b/deploy/adapters/ansible/roles/ceilometer_controller/vars/main.yml new file mode 100644 index 00000000..bb87da65 --- /dev/null +++ b/deploy/adapters/ansible/roles/ceilometer_controller/vars/main.yml @@ -0,0 +1,3 @@ +--- +packages_noarch: [] +metering_secret: 1c5df72079b31fb47747 diff --git a/deploy/adapters/ansible/roles/common/tasks/main.yml b/deploy/adapters/ansible/roles/common/tasks/main.yml index ead70aed..0b72d6e2 100644 --- a/deploy/adapters/ansible/roles/common/tasks/main.yml +++ b/deploy/adapters/ansible/roles/common/tasks/main.yml @@ -13,6 +13,9 @@ dest=/etc/hosts backup=yes +- name: make config template dir exist + file: path=/opt/os_templates state=directory mode=0755 + - name: get compass-core hostname local_action: shell hostname register: name diff --git a/deploy/adapters/ansible/roles/common/vars/Debian.yml b/deploy/adapters/ansible/roles/common/vars/Debian.yml index 0890c757..c471d148 100644 --- a/deploy/adapters/ansible/roles/common/vars/Debian.yml +++ b/deploy/adapters/ansible/roles/common/vars/Debian.yml @@ -4,6 +4,7 @@ packages: - python-dev - openvswitch-datapath-dkms - openvswitch-switch + - crudini services: [] diff --git a/deploy/adapters/ansible/roles/dashboard/templates/ports.j2 b/deploy/adapters/ansible/roles/dashboard/templates/ports.j2 new file mode 100755 index 00000000..0bfa0428 --- /dev/null +++ b/deploy/adapters/ansible/roles/dashboard/templates/ports.j2 @@ -0,0 +1,15 @@ +# if you just change the port or add more ports here, you will likely also +# have to change the VirtualHost statement in +# /etc/apache2/sites-enabled/000-default.conf + +Listen {{ internal_ip }}:80 + +<IfModule ssl_module> + Listen 443 +</IfModule> + +<IfModule mod_gnutls.c> + Listen 443 +</IfModule> + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/deploy/adapters/ansible/roles/database/tasks/main.yml b/deploy/adapters/ansible/roles/database/tasks/main.yml index 71916751..ad5c5b71 100644 --- a/deploy/adapters/ansible/roles/database/tasks/main.yml +++ b/deploy/adapters/ansible/roles/database/tasks/main.yml @@ -1,14 +1,11 @@ --- - include_vars: "{{ ansible_os_family }}.yml" -- name: copy data.sh - template: src=data.j2 dest=/opt/data.sh mode=777 - tags: - - mysql_user - - include: mysql.yml when: haproxy_hosts is not defined - include: mariadb.yml when: haproxy_hosts is defined +- include: mongodb.yml + diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb.yml index 3626777b..37c9a2c9 100644 --- a/deploy/adapters/ansible/roles/database/tasks/mariadb.yml +++ b/deploy/adapters/ansible/roles/database/tasks/mariadb.yml @@ -24,32 +24,60 @@ - name: update wsrep_sst_rsync gid lineinfile: dest=/usr/bin/wsrep_sst_rsync state=absent regexp="\s*gid = \$MYGID$" backup=yes +- stat: path=/opt/mysql_init_complete + register: mysql_init_complete + - name: restart first mysql server shell: service mysql restart --wsrep-cluster-address="gcomm://" - when: inventory_hostname == haproxy_hosts.keys()[0] - register: result - until: result|success - retries: 5 - delay: 5 + args: + creates: /opt/mysql_init_complete + when: inventory_hostname == haproxy_hosts.keys()[0] and mysql_init_complete.stat.exists == False tags: - mysql_restart + #register: result + #until: result|success + #retries: 5 + #delay: 5 - name: restart other mysql server - service: name=mysql state=restarted enabled=yes - when: inventory_hostname != haproxy_hosts.keys()[0] - register: result - until: result|success - retries: 5 - delay: 5 + shell: service mysql restart + args: + creates: /opt/mysql_init_complete tags: - mysql_restart + when: inventory_hostname != haproxy_hosts.keys()[0] and mysql_init_complete.stat.exists == False + #register: result + #until: result|success + #retries: 5 + #delay: 5 - name: generate mysql service list shell: echo {{ item }} >> /opt/service with_items: services_noarch -- name: create database/user - shell: /opt/data.sh - run_once: True - tags: - - mysql_user +- name: create all needed db + run_once: yes + mysql_db: name={{ item.db }} state=present + with_items: "{{ credentials }}" + +- name: create service db user + run_once: yes + mysql_user: + name={{ item[0].user }} + password={{ item[0].password }} + priv=*.*:ALL,GRANT + host={{ item[1] }} + state=present + with_nested: + - "{{ credentials }}" + - ['%', 'localhost', inventory_hostname] + +- name: create wsrep db user + run_once: yes + mysql_user: + name={{ WSREP_SST_USER }} + password={{ WSREP_SST_PASS }} + priv=*.*:ALL,GRANT + host={{ item }} + state=present + with_items: ['%', 'localhost', inventory_hostname] diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb.yml new file mode 100644 index 00000000..a0edcce8 --- /dev/null +++ b/deploy/adapters/ansible/roles/database/tasks/mongodb.yml @@ -0,0 +1,32 @@ +--- +- name: install mongodb packages + action: "{{ ansible_pkg_mgr }} name={{ item }} state=present" + with_items: mongodb_packages | union(packages_noarch) + +- name: copy ceilometer configs + template: src=mongodb.conf dest=/opt/os_templates backup=yes + +- name: update mongodb config file + shell: crudini --merge /etc/mongodb.conf < /opt/os_templates/mongodb.conf + +- name: rm prealloc files + file: + dest: "{{ item }}" + state: absent + with_fileglob: + - /var/lib/mongodb/journal/* + +- name: manually restart mongodb server + service: name=mongodb state=restarted + +- wait_for: port=27017 delay=3 timeout=10 host={{ internal_vip.ip }} + +- name: create mongodb user + run_once: True + mongodb_user: + login_host: "{{ internal_vip.ip }}" + database: ceilometer + name: ceilometer + password: "{{ CEILOMETER_DBPASS }}" + roles: 'readWrite,dbAdmin' + state: present diff --git a/deploy/adapters/ansible/roles/database/templates/mongodb.conf b/deploy/adapters/ansible/roles/database/templates/mongodb.conf new file mode 100644 index 00000000..68b84d7a --- /dev/null +++ b/deploy/adapters/ansible/roles/database/templates/mongodb.conf @@ -0,0 +1,4 @@ +# mongodb.conf +bind_ip = {{ internal_vip.ip }} +port = 27017 +smallfiles = true diff --git a/deploy/adapters/ansible/roles/database/vars/Debian.yml b/deploy/adapters/ansible/roles/database/vars/Debian.yml index 15657d58..6f085ffd 100644 --- a/deploy/adapters/ansible/roles/database/vars/Debian.yml +++ b/deploy/adapters/ansible/roles/database/vars/Debian.yml @@ -1,4 +1,8 @@ --- +mongodb_packages: + - mongodb-server + - mongodb-clients + - python-pymongo mysql_packages: - python-mysqldb diff --git a/deploy/adapters/ansible/roles/database/vars/main.yml b/deploy/adapters/ansible/roles/database/vars/main.yml index e497cd92..e71c1d4c 100644 --- a/deploy/adapters/ansible/roles/database/vars/main.yml +++ b/deploy/adapters/ansible/roles/database/vars/main.yml @@ -3,3 +3,21 @@ packages_noarch: [] services_noarch: - mysql + +credentials: + - user: keystone + db: keystone + password: "{{ KEYSTONE_DBPASS }}" + - user: neutron + db: neutron + password: "{{ NEUTRON_DBPASS }}" + - user: glance + db: glance + password: "{{ GLANCE_DBPASS }}" + - user: nova + db: nova + password: "{{ NOVA_DBPASS }}" + - user: cinder + db: cinder + password: "{{ CINDER_DBPASS }}" + diff --git a/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg b/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg index 27aa5b24..721c9731 100644 --- a/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg +++ b/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg @@ -131,6 +131,17 @@ listen proxy-cinder_api_cluster server {{ host }} {{ ip }}:8776 weight 1 check inter 2000 rise 2 fall 5 {% endfor %} +listen proxy-ceilometer_api_cluster + bind {{ internal_vip.ip }}:8777 + bind {{ public_vip.ip }}:8777 + mode tcp + option httpchk + option tcplog + balance source +{% for host,ip in haproxy_hosts.items() %} + server {{ host }} {{ ip }}:8777 weight 1 check inter 2000 rise 2 fall 5 +{% endfor %} + listen proxy-dashboarad bind {{ public_vip.ip }}:80 option tcpka diff --git a/deploy/adapters/ansible/roles/keystone/templates/keystone_init b/deploy/adapters/ansible/roles/keystone/templates/keystone_init index c7e22324..0ea6e08a 100644 --- a/deploy/adapters/ansible/roles/keystone/templates/keystone_init +++ b/deploy/adapters/ansible/roles/keystone/templates/keystone_init @@ -45,3 +45,10 @@ keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }} keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 user-role-add --user neutron --tenant service --role admin keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 service-create --name neutron --type network --description "OpenStack Networking" keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 endpoint-create --service-id $(keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 service-list | awk '/ network / {print $2}') --publicurl http://{{ public_vip.ip }}:9696 --adminurl http://{{ internal_vip.ip }}:9696 --internalurl http://{{ internal_vip.ip }}:9696 + + +# register ceilometer related +keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 user-create --name ceilometer --pass {{ CEILOMETER_PASS }} --email ceilometer@example.com +keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 user-role-add --user ceilometer --tenant service --role admin +keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 service-create --name ceilometer --type metering --description "OpenStack Telemetry" +keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 endpoint-create --service-id $(keystone --os-token={{ ADMIN_TOKEN }} --os-endpoint=http://{{ internal_vip.ip }}:35357/v2.0 service-list | awk '/ metering / {print $2}') --publicurl http://{{ public_vip.ip }}:8777 --adminurl http://{{ internal_vip.ip }}:8777 --internalurl http://{{ internal_vip.ip }}:8777 |