Skip to content

Commit b937541

Browse files
committed
Fixed cf-remote install hub does not set password
Ticket: ENT-13655 Signed-off-by: Victor Moene <victor.moene@northern.tech>
1 parent a7537be commit b937541

File tree

3 files changed

+35
-27
lines changed

3 files changed

+35
-27
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include cf_remote/nt-discovery.sh
22
include cf_remote/Vagrantfile
33
include cf_remote/default_provision.sh
4+
include cf_remote/demo.sql

cf_remote/demo.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,12 @@
11
import os
22
import json
3+
from posixpath import dirname, join
34

45
from cf_remote import log
56
from cf_remote.paths import cf_remote_dir
67
from cf_remote.utils import save_file
78
from cf_remote.ssh import scp, ssh_sudo, ssh_cmd, auto_connect
89

9-
SET_ADMIN_PASSWORD_QUERY = """UPDATE
10-
\"system\"
11-
SET
12-
\"value\" = 'true'
13-
WHERE
14-
\"key\" = 'is_setup_complete';
15-
INSERT
16-
INTO
17-
\"users\"
18-
(\"username\", \"password\", \"salt\", \"name\", \"email\", \"external\", \"active\", \"roles\", \"changetimestamp\") SELECT
19-
'admin',
20-
'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
21-
'eWAbKQmxNP',
22-
'admin',
23-
'admin@organisation.com',
24-
false,
25-
'1',
26-
'{admin,cf_remoteagent}',
27-
now()
28-
ON CONFLICT (username,
29-
external) DO UPDATE
30-
31-
SET
32-
password = 'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
33-
salt = 'eWAbKQmxNP';"""
34-
3510

3611
@auto_connect
3712
def agent_run(data, *, connection=None):
@@ -50,9 +25,14 @@ def agent_run(data, *, connection=None):
5025
@auto_connect
5126
def disable_password_dialog(host, *, connection=None):
5227
print("Disabling password change on hub: '{}'".format(host))
28+
29+
query_path = join(dirname(__file__), "demo.sql")
30+
scp(query_path, host, connection=connection)
31+
32+
query = os.path.basename(query_path)
5333
ssh_sudo(
5434
connection,
55-
'/var/cfengine/bin/psql cfsettings -c "{}"'.format(SET_ADMIN_PASSWORD_QUERY),
35+
'/var/cfengine/bin/psql cfsettings -f "{}"'.format(query),
5636
)
5737

5838

cf_remote/demo.sql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
UPDATE "system"
2+
SET "value" = 'true'
3+
WHERE "key" = 'is_setup_complete';
4+
5+
6+
INSERT INTO "users" ("username",
7+
"password",
8+
"salt",
9+
"name",
10+
"email",
11+
"external",
12+
"active",
13+
"roles",
14+
"changetimestamp")
15+
SELECT 'admin',
16+
'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
17+
'eWAbKQmxNP',
18+
'admin',
19+
'admin@organisation.com',
20+
FALSE,
21+
'1',
22+
'{admin,cf_remoteagent}',
23+
now() ON CONFLICT (username,
24+
EXTERNAL) DO
25+
UPDATE
26+
SET password = 'SHA=7f062dc2ef82d2b87f012fc17d70c372aa4e2883d9b6c5c1cc7382a5c868b724',
27+
salt = 'eWAbKQmxNP';

0 commit comments

Comments
 (0)