Script to set moeny user password
This commit is contained in:
parent
de6252a4ee
commit
887536ced7
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ bolt-debug.log
|
||||
.plugin_cache.json
|
||||
.task_cache.json
|
||||
.rerun.json
|
||||
keys
|
@ -154,6 +154,13 @@ steps:
|
||||
install_docker_bool: $install_docker_bool
|
||||
staging_ip: $staging_ip
|
||||
|
||||
- name: set_moeny_password
|
||||
description: Set password for moeny user
|
||||
task: alpine::set_moeny_password
|
||||
targets: localhost
|
||||
parameters:
|
||||
staging_ip: $staging_ip
|
||||
|
||||
- name: system_setup
|
||||
task: alpine::system_setup
|
||||
targets: localhost
|
||||
|
26
vm_automation/alpine/tasks/set_moeny_password.sh
Normal file
26
vm_automation/alpine/tasks/set_moeny_password.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# Task to set password for moeny user (alpine::set_moeny_password)
|
||||
|
||||
# Input Variables
|
||||
STAGING_IP="${PT_staging_ip}"
|
||||
|
||||
# Function to check last command status
|
||||
check_status() {
|
||||
if [ $? -ne 0 ]; then
|
||||
echo '{"status": "error", "message": "'"$1"'"}'
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Generate a random 15-character password locally
|
||||
echo "Generating password..."
|
||||
MOENY_PASSWORD=$(head -c 30 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | head -c 15)
|
||||
echo "Debug - Generated password: ${MOENY_PASSWORD}"
|
||||
check_status "Failed to generate password"
|
||||
|
||||
# Set the password for moeny user
|
||||
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "echo 'moeny:${MOENY_PASSWORD}' | chpasswd"
|
||||
check_status "Failed to set password for moeny user"
|
||||
|
||||
echo '{"status": "success", "message": "Moeny user password set to: '"${MOENY_PASSWORD}"'"}'
|
||||
exit 0
|
@ -135,6 +135,11 @@ steps:
|
||||
parameters:
|
||||
install_docker_bool: $install_docker_bool
|
||||
|
||||
- name: set_moeny_password
|
||||
description: Set password for moeny user
|
||||
task: ubuntu::set_moeny_password
|
||||
targets: $staging_ip
|
||||
|
||||
- name: system_setup
|
||||
task: ubuntu::system_setup
|
||||
targets: $staging_ip
|
||||
|
@ -30,4 +30,4 @@ virt-install \
|
||||
--autostart \
|
||||
--wait -1
|
||||
|
||||
sleep 45
|
||||
sleep 90
|
21
vm_automation/ubuntu/tasks/set_moeny_password.sh
Executable file
21
vm_automation/ubuntu/tasks/set_moeny_password.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
# Task to set password for moeny user (ubuntu::set_moeny_password)
|
||||
|
||||
# Function to check last command status
|
||||
check_status() {
|
||||
if [ $? -ne 0 ]; then
|
||||
echo '{"status": "error", "message": "'"$1"'"}'
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Generate a random 15-character password (alphanumeric only)
|
||||
MOENY_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n 1)
|
||||
check_status "Failed to generate password"
|
||||
|
||||
# Set the password for moeny user
|
||||
echo "moeny:${MOENY_PASSWORD}" | sudo chpasswd
|
||||
check_status "Failed to set password for moeny user"
|
||||
|
||||
echo '{"status": "success", "message": "Moeny user password set to: '"${MOENY_PASSWORD}"'"}'
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user