Skip to content

Commit

Permalink
Set up database and users.
Browse files Browse the repository at this point in the history
  • Loading branch information
bigjools committed Feb 3, 2017
1 parent 09e7d62 commit 7c55d1e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
11 changes: 11 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,14 @@ keystone_auth_admin_password: "{{ secrets.keystone.users.admin_password }}"
keystone_admin_tenant_name: "admin"
keystone_service_adminurl: "{{ keystone_protocol }}://{{ keystone_hostname }}:{{ keystone_admin_port }}/v3"
keystone_service_adminuri_insecure: true

ironic_users_to_create:
- name: ironic
password: ironic
privs:
- "ironic.*:ALL"
hosts:
- localhost
- 127.0.0.1
- "{{ (network_pools.admin_net[mc_class]|net_range_to_list) }}"

33 changes: 32 additions & 1 deletion tasks/ironic_db_setup.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# Copyright 2015, Rackspace US, Inc.
# Copyright 2017 Cisco Systems
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Create database
mysql_db: collation={{ mysql_db_collation }}
encoding={{ mysql_db_encoding }}
name=ironic
no_log: True
run_once: True

- name: Create database user
mysql_user: append_privs={{ item.append_privs|default(omit) }}
check_implicit_admin={{ item.check_implicit|default(omit) }}
config_file={{ item.config_file|default(omit) }}
encrypted={{ item.encrypted|default(omit) }}
host={{ item.host|default(omit) }}
host_all={{ item.host_all|default(omit) }}
login_host={{ item.login_host|default(omit) }}
login_password={{ item.login_password|default(omit) }}
login_port={{ item.login_port|default(omit) }}
login_unix_socket={{ percona_socket }}
login_user={{ item.login_user|default(omit) }}
name={{ item.name|default(omit) }}
password={{ item.password|default(omit) }}
priv={{ item.priv|default(omit) }}
ssl_ca={{ item.ssl_ca|default(omit) }}
ssl_cert={{ item.ssl_cert|default(omit) }}
ssl_key={{ item.ssl_key|default(omit) }}
state={{ item.state|default(omit) }}
update_password={{ item.update_password|default(omit) }}
with_items: "{{ ironic_users_to_create | format_mysql_users }}"
no_log: True
run_once: True

- name: Update database schema
command: "{{ ironic_bin }}/ironic-dbsync upgrade"
become: yes
Expand Down

0 comments on commit 7c55d1e

Please sign in to comment.