7c58ec3dc87a757577dd9474d89acb4682a8d223
[armband.git] / patches / opnfv-fuel / 0013-Add-opnfv-user-to-the-deployment.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 Enea AB and others.
3 :
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Charalampos Kominos <Charalampos.Kominos@enea.com>
10 Date: Fri, 1 Sep 2017 12:24:35 +0200
11 Subject: [PATCH] Add opnfv user to the deployment
12
13 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
14 Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com>
15 Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
16 ---
17  mcp/config/states/virtual_control_plane                         | 2 ++
18  mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml | 4 ++++
19  mcp/salt-formulas/opnfv/adduser.sls                             | 7 +++++++
20  3 files changed, 13 insertions(+)
21  create mode 100644 mcp/salt-formulas/opnfv/adduser.sls
22
23 diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
24 index 1657d3c..4b3ec42 100755
25 --- a/mcp/config/states/virtual_control_plane
26 +++ b/mcp/config/states/virtual_control_plane
27 @@ -37,6 +37,7 @@ salt -C 'kvm* or cmp*' file.replace $debian_ip_source \
28    repl="\n        if not __salt__['pkg.version']('vlan'):\n            __salt__['pkg.install']('vlan')"
29
30  salt -C 'kvm*' pkg.install bridge-utils
31 +salt -C '*' state.apply opnfv.adduser
32  salt -C 'kvm*' state.apply linux.network
33  salt -C 'cmp*' state.apply linux.system
34  salt -C 'cmp*' state.apply linux.network || true
35 @@ -67,6 +68,7 @@ while [ $rc -ne 0 ] && [ ${attempt} -lt ${total_attempts} ]; do
36    rc=0
37    for node in $vcp_nodes; do
38      salt "$node" test.ping 2>/dev/null || { rc=$?; break; };
39 +    salt -C "$node" state.apply opnfv.adduser
40    done
41    sleep 5
42    ((attempt+=1))
43 diff --git a/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml b/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml
44 index aa780e6..e4069c0 100644
45 --- a/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml
46 +++ b/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml
47 @@ -9,3 +9,7 @@
48  classes:
49    - cluster.all-mcp-ocata-common.opnfv.runtime
50    - cluster.all-mcp-ocata-common.opnfv.pod_config
51 +parameters:
52 +  _param:
53 +    opnfv_user_username: opnfv
54 +    opnfv_user_password: $1$5/pIEHT1$XFBhNWW4Q8gYd19hczgPF1
55 diff --git a/mcp/salt-formulas/opnfv/adduser.sls b/mcp/salt-formulas/opnfv/adduser.sls
56 new file mode 100644
57 index 0000000..78ef993
58 --- /dev/null
59 +++ b/mcp/salt-formulas/opnfv/adduser.sls
60 @@ -0,0 +1,7 @@
61 +add_opnfv_user:
62 +  user.present:
63 +  - name: {{ salt['pillar.get']('_param:opnfv_user_username') }}
64 +  - password: {{ salt['pillar.get']('_param:opnfv_user_password') }}
65 +  - createhome: True
66 +  - groups:
67 +    - sudo