diff options
Diffstat (limited to 'deploy/adapters/ansible/roles/database')
6 files changed, 104 insertions, 21 deletions
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 }}" + |