Move database creation into role
There is no record for why we implement the database creation outside of the role in the playbook, when we could do it inside the role. Implementing it inside the role allows us to reduce the quantity of group_vars duplicated from the role, and allows us to better document the required variables in the role. The delegation can still be done as it is done in the playbook too. In this patch we implement a new variable called 'rally_db_setup_host' which is used in the role to allow delegation of the database setup task to any host, but defaults to the first member of the galera_all host group. We also document the variable 'rally_galera_address' which has been used for a long time, but never documented. A bunch of unused variables have also been removed. Change-Id: Ifb89e35e3acaef33ce4ce24b3f5affc6c4e8e494
This commit is contained in:
parent
10f2b43366
commit
c4e6c8ce30
@ -46,6 +46,8 @@ rally_venv_download: "{{ not rally_developer_mode | bool }}"
|
||||
rally_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/rally.tgz
|
||||
|
||||
# Database vars
|
||||
rally_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}"
|
||||
rally_galera_address: "{{ galera_address | default('127.0.0.1') }}"
|
||||
rally_galera_database: rally
|
||||
rally_galera_user: rally
|
||||
rally_database_connection_string: mysql+pymysql://{{ rally_galera_user }}:{{ rally_galera_password }}@{{ rally_galera_address }}/{{ rally_galera_database }}?charset=utf8
|
||||
|
@ -13,6 +13,32 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Create DB for service
|
||||
mysql_db:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "{{ rally_galera_address }}"
|
||||
name: "{{ rally_galera_database }}"
|
||||
state: "present"
|
||||
delegate_to: "{{ rally_db_setup_host }}"
|
||||
no_log: True
|
||||
|
||||
- name: Grant access to the DB for the service
|
||||
mysql_user:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "{{ rally_galera_address }}"
|
||||
name: "{{ rally_galera_user }}"
|
||||
password: "{{ rally_galera_password }}"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "{{ rally_galera_database }}.*:ALL"
|
||||
delegate_to: "{{ rally_db_setup_host }}"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
no_log: True
|
||||
|
||||
- name: Check for db
|
||||
command: "{{ rally_bin }}/rally deployment list"
|
||||
changed_when: false
|
||||
|
@ -13,8 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
rally_galera_address: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}"
|
||||
rally_galera_database: rally
|
||||
rally_galera_password: "SuperSecrete"
|
||||
rally_venv_tag: "testing"
|
||||
rally_venv_download: False
|
||||
|
@ -17,33 +17,6 @@
|
||||
hosts: utility_all
|
||||
user: root
|
||||
gather_facts: true
|
||||
pre_tasks:
|
||||
- name: Create DB for service
|
||||
mysql_db:
|
||||
login_user: "root"
|
||||
login_password: "secrete"
|
||||
login_host: "localhost"
|
||||
name: "{{ rally_galera_database }}"
|
||||
state: "present"
|
||||
delegate_to: "10.100.100.2"
|
||||
when: inventory_hostname == groups['utility_all'][0]
|
||||
no_log: true
|
||||
- name: Grant access to the DB for the service
|
||||
mysql_user:
|
||||
login_user: "root"
|
||||
login_password: "secrete"
|
||||
login_host: "localhost"
|
||||
name: "{{ rally_galera_database }}"
|
||||
password: "{{ rally_galera_password }}"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "{{ rally_galera_database }}.*:ALL"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
delegate_to: "10.100.100.2"
|
||||
when: inventory_hostname == groups['utility_all'][0]
|
||||
no_log: true
|
||||
roles:
|
||||
- role: "os_rally"
|
||||
vars_files:
|
||||
|
Loading…
Reference in New Issue
Block a user