Commit c2d6d9b8 authored by Dobli's avatar Dobli
Browse files

Restricted admin user to ohadmin

parent 2f7ad04a
...@@ -38,9 +38,7 @@ EDIT_FILES = { ...@@ -38,9 +38,7 @@ EDIT_FILES = {
"known_hosts": "ssh/known_hosts", "known_hosts": "ssh/known_hosts",
"backup_config": "volumerize/backup_config.json" "backup_config": "volumerize/backup_config.json"
} }
CONSTRAINTS = { CONSTRAINTS = {"building": "node.labels.building"}
"building": "node.labels.building"
}
SERVICES = { SERVICES = {
"sftp": "sftp_X", "sftp": "sftp_X",
"openhab": "openhab_X", "openhab": "openhab_X",
...@@ -52,6 +50,8 @@ SERVICES = { ...@@ -52,6 +50,8 @@ SERVICES = {
SWARM_PORT = 2377 SWARM_PORT = 2377
# UID for admin # UID for admin
UID = 9001 UID = 9001
# Username for admin
ADMIN_USER = 'ohadmin'
# ****************************** # ******************************
# Compose file functions {{{ # Compose file functions {{{
...@@ -220,6 +220,7 @@ def get_service_template(base_dir, service_name): ...@@ -220,6 +220,7 @@ def get_service_template(base_dir, service_name):
return template_content['services'][service_name] return template_content['services'][service_name]
# }}} # }}}
...@@ -557,6 +558,8 @@ def generate_swarm(machines): ...@@ -557,6 +558,8 @@ def generate_swarm(machines):
print(f'Machine {machine} joins swarm of leader {leader}') print(f'Machine {machine} joins swarm of leader {leader}')
if (join_swarm_machine(machine, leader)): if (join_swarm_machine(machine, leader)):
print('Joining swarm successful\n') print('Joining swarm successful\n')
# }}} # }}}
...@@ -681,7 +684,7 @@ def interactive_command(args): ...@@ -681,7 +684,7 @@ def interactive_command(args):
:args: parsed command line arguments :args: parsed command line arguments
""" """
print(main_menu(args)) main_menu(args)
# }}} # }}}
...@@ -724,36 +727,44 @@ def init_menu(args): ...@@ -724,36 +727,44 @@ def init_menu(args):
base_dir = os.getcwd() base_dir = os.getcwd()
# Prompts # Prompts
questions = [{ questions = [
'type': 'input',
'name': 'stack_name',
'message': 'Choose a name for your setup'
},
{ {
'type': 'checkbox', 'type': 'input',
'name': 'machines', 'name': 'stack_name',
'message': 'What docker machines will be used?', 'message': 'Choose a name for your setup'
'choices': generate_checkbox_choices(get_machine_list()) },
},
{ {
'type': 'input', 'type': 'checkbox',
'name': 'username', 'name': 'machines',
'message': 'Choose a username for the admin user' 'message': 'What docker machines will be used?',
}] 'choices': generate_checkbox_choices(get_machine_list())
}
# },
# {
# 'type': 'input',
# 'name': 'username',
# 'message': 'Choose a username for the admin user'
]
answers = prompt(questions) answers = prompt(questions)
# Ensure passwords match # Ensure passwords match
password_match = False password_match = False
while not password_match: while not password_match:
password_questions = [{ password_questions = [{
'type': 'password', 'type':
'name': 'password', 'password',
'message': 'Choose a password for the admin user:', 'name':
'password',
'message':
'Choose a password for the ohadmin user:',
}, },
{ {
'type': 'password', 'type':
'name': 'confirm', 'password',
'message': 'Repeat password for the admin user', 'name':
'confirm',
'message':
'Repeat password for the ohadmin user',
}] }]
password_answers = prompt(password_questions) password_answers = prompt(password_questions)
if password_answers['password'] == password_answers['confirm']: if password_answers['password'] == password_answers['confirm']:
...@@ -765,7 +776,7 @@ def init_menu(args): ...@@ -765,7 +776,7 @@ def init_menu(args):
generate_config_folders(base_dir) generate_config_folders(base_dir)
generate_initial_compose(base_dir) generate_initial_compose(base_dir)
# Generate config files based on input # Generate config files based on input
username = answers['username'] username = ADMIN_USER
password = password_answers['password'] password = password_answers['password']
hosts = answers['machines'] hosts = answers['machines']
generate_sftp_file(base_dir, username, password) generate_sftp_file(base_dir, username, password)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment