Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting MIQ admin password during deployment #250

Merged
merged 4 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions images/miq-app/docker-assets/appliance-initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ case $? in

# Restore symlinks from PV to application rootdir
restore_pv_data

set_admin_pwd
;;
4) # new_replica
echo "== Starting New Replica =="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ function migrate_db() {
) 2>&1 | tee ${PV_MIGRATE_DB_LOG}
}

# Set EVM admin pwd
function set_admin_pwd() {
echo "== Setting admin password =="

cd ${APP_ROOT} && bin/rails runner "EvmDatabase.seed_primordial; user = User.find_by_userid('admin').update_attributes!(:password => ENV['APPLICATION_ADMIN_PASSWORD'])"

[ "$?" -ne "0" ] && echo "ERROR: Failed to set admin password, please check appliance logs"
}

# Process DATA_PERSIST_FILE which contains the desired files/dirs to store on the PV
# Use rsync to transfer files/dirs, log output and check return status
# Ensure we always store an initial data backup on PV
Expand Down
11 changes: 11 additions & 0 deletions templates/miq-template-ext-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ objects:
name: "${NAME}-secrets"
stringData:
pg-password: "${DATABASE_PASSWORD}"
admin-password: "${APPLICATION_ADMIN_PASSWORD}"
database-url: postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_SERVICE_NAME}/${DATABASE_NAME}?encoding=utf8&pool=5&wait_timeout=5
v2-key: "${V2_KEY}"
- apiVersion: v1
Expand Down Expand Up @@ -126,6 +127,11 @@ objects:
secretKeyRef:
name: "${NAME}-secrets"
key: v2-key
- name: APPLICATION_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: "${NAME}-secrets"
key: admin-password
- name: ANSIBLE_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -751,6 +757,11 @@ parameters:
displayName: Application Database Region
description: Database region that will be used for application.
value: '0'
- name: APPLICATION_ADMIN_PASSWORD
displayName: Application Admin Password
required: true
description: Admin password that will be set on the application.
value: smartvm
- name: ANSIBLE_DATABASE_NAME
displayName: Ansible PostgreSQL database name
required: true
Expand Down
11 changes: 11 additions & 0 deletions templates/miq-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ objects:
name: "${NAME}-secrets"
stringData:
pg-password: "${DATABASE_PASSWORD}"
admin-password: "${APPLICATION_ADMIN_PASSWORD}"
database-url: postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_SERVICE_NAME}/${DATABASE_NAME}?encoding=utf8&pool=5&wait_timeout=5
v2-key: "${V2_KEY}"
- apiVersion: v1
Expand Down Expand Up @@ -387,6 +388,11 @@ objects:
secretKeyRef:
name: "${NAME}-secrets"
key: v2-key
- name: APPLICATION_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: "${NAME}-secrets"
key: admin-password
- name: ANSIBLE_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -888,6 +894,11 @@ parameters:
displayName: Application Database Region
description: Database region that will be used for application.
value: '0'
- name: APPLICATION_ADMIN_PASSWORD
displayName: Application Admin Password
required: true
description: Admin password that will be set on the application.
value: smartvm
- name: ANSIBLE_DATABASE_NAME
displayName: Ansible PostgreSQL database name
required: true
Expand Down