Skip to content
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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include cf_remote/nt-discovery.sh
include cf_remote/Vagrantfile
include cf_remote/default_provision.sh
include cf_remote/demo.sql
34 changes: 7 additions & 27 deletions cf_remote/demo.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
import os
import json
from posixpath import dirname, join

from cf_remote import log
from cf_remote.paths import cf_remote_dir
from cf_remote.utils import save_file
from cf_remote.ssh import scp, ssh_sudo, ssh_cmd, auto_connect

SET_ADMIN_PASSWORD_QUERY = """UPDATE
\"system\"
SET
\"value\" = 'true'
WHERE
\"key\" = 'is_setup_complete';
INSERT
INTO
\"users\"
(\"username\", \"password\", \"salt\", \"name\", \"email\", \"external\", \"active\", \"roles\", \"changetimestamp\") SELECT
'admin',
'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
'eWAbKQmxNP',
'admin',
'admin@organisation.com',
false,
'1',
'{admin,cf_remoteagent}',
now()
ON CONFLICT (username,
external) DO UPDATE

SET
password = 'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
salt = 'eWAbKQmxNP';"""


@auto_connect
def agent_run(data, *, connection=None):
Expand All @@ -50,9 +25,14 @@ def agent_run(data, *, connection=None):
@auto_connect
def disable_password_dialog(host, *, connection=None):
print("Disabling password change on hub: '{}'".format(host))

query_path = join(dirname(__file__), "demo.sql")
scp(query_path, host, connection=connection)

query = os.path.basename(query_path)
ssh_sudo(
connection,
'/var/cfengine/bin/psql cfsettings -c "{}"'.format(SET_ADMIN_PASSWORD_QUERY),
'/var/cfengine/bin/psql cfsettings -f "{}"'.format(query),
)


Expand Down
27 changes: 27 additions & 0 deletions cf_remote/demo.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
UPDATE "system"
SET "value" = 'true'
WHERE "key" = 'is_setup_complete';


INSERT INTO "users" ("username",
"password",
"salt",
"name",
"email",
"external",
"active",
"roles",
"changetimestamp")
SELECT 'admin',
'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
'eWAbKQmxNP',
'admin',
'admin@organisation.com',
FALSE,
'1',
'{admin,cf_remoteagent}',
now() ON CONFLICT (username,
EXTERNAL) DO
UPDATE
SET password = 'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
salt = 'eWAbKQmxNP';