Skip to content

Commit

Permalink
Merge pull request #250 from fbladilo/allow_set_app_admin_pwd
Browse files Browse the repository at this point in the history
Allow setting MIQ admin password during deployment
(cherry picked from commit 941a134)
  • Loading branch information
carbonin authored and simaishi committed Dec 11, 2017
1 parent ca223dd commit 8786454
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
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

0 comments on commit 8786454

Please sign in to comment.