Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
9bd8d5fa
Commit
9bd8d5fa
authored
Feb 01, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generate ansible k8s
parent
8ed128bc
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
132 additions
and
36 deletions
+132
-36
__main__.py
deployer/__main__.py
+2
-2
ansible_service.py
deployer/service/ansible_service.py
+27
-23
k8s_service.py
deployer/service/k8s_service.py
+12
-10
drip-deployer.iml
drip-deployer/.idea/drip-deployer.iml
+8
-0
profiles_settings.xml
drip-deployer/.idea/inspectionProfiles/profiles_settings.xml
+6
-0
modules.xml
drip-deployer/.idea/modules.xml
+8
-0
vcs.xml
drip-deployer/.idea/vcs.xml
+6
-0
workspace.xml
drip-deployer/.idea/workspace.xml
+48
-0
nbactions.xml
provisioner/nbactions.xml
+14
-0
pom.xml
provisioner/pom.xml
+1
-1
No files found.
deployer/__main__.py
View file @
9bd8d5fa
...
@@ -76,10 +76,10 @@ def handle_delivery(message):
...
@@ -76,10 +76,10 @@ def handle_delivery(message):
paths
=
ansible_service
.
write_playbooks_from_tosca_interface
(
interfaces
,
tmp_path
)
paths
=
ansible_service
.
write_playbooks_from_tosca_interface
(
interfaces
,
tmp_path
)
for
playbook_path
in
paths
:
for
playbook_path
in
paths
:
out
,
err
=
ansible_service
.
run
(
inventory_path
,
playbook_path
)
out
,
err
=
ansible_service
.
run
(
inventory_path
,
playbook_path
)
api_key
,
join_token
,
discovery_token_ca_cert_hash
=
ansible_service
.
parse_tokens
(
out
)
api_key
,
join_token
,
discovery_token_ca_cert_hash
=
ansible_service
.
parse_tokens
(
out
.
decode
(
"utf-8"
)
)
ansible_playbook_path
=
k8s_service
.
write_ansible_k8s_files
(
tosca_template_json
,
tmp_path
)
ansible_playbook_path
=
k8s_service
.
write_ansible_k8s_files
(
tosca_template_json
,
tmp_path
)
out
,
err
=
ansible_service
.
run
(
inventory_path
,
playbook_path
)
out
,
err
=
ansible_service
.
run
(
inventory_path
,
ansible_
playbook_path
)
template_dict
=
{}
template_dict
=
{}
...
...
deployer/service/ansible_service.py
View file @
9bd8d5fa
...
@@ -71,7 +71,7 @@ def write_inventory_file(tmp_path, vms):
...
@@ -71,7 +71,7 @@ def write_inventory_file(tmp_path, vms):
def
write_playbooks
(
tmp_path
,
interface
):
def
write_playbooks
(
tmp_path
,
interface
):
playbook_paths
=
[]
playbook_paths
=
[]
interface_stage_list
=
[
'install'
,
'create'
]
interface_stage_list
=
[
'install'
,
'create'
]
# for interface_stage in interface:
# for interface_stage in interface:
for
interface_stage
in
interface_stage_list
:
for
interface_stage
in
interface_stage_list
:
playbook_url
=
interface
[
interface_stage
][
'inputs'
][
'playbook'
]
playbook_url
=
interface
[
interface_stage
][
'inputs'
][
'playbook'
]
...
@@ -101,6 +101,10 @@ def run(inventory_path, playbook_path):
...
@@ -101,6 +101,10 @@ def run(inventory_path, playbook_path):
def
parse_tokens
(
out
):
def
parse_tokens
(
out
):
api_key
=
None
join_token
=
None
discovery_token_ca_cert_hash
=
None
if
'Join command is kubeadm join'
in
out
:
api_key
=
re
.
search
(
"^msg.*"
,
out
)
api_key
=
re
.
search
(
"^msg.*"
,
out
)
join_token
=
re
.
search
(
"^
\"
stdout
\"
:
\"
$"
,
out
)
join_token
=
re
.
search
(
"^
\"
stdout
\"
:
\"
$"
,
out
)
...
...
deployer/service/k8s_service.py
View file @
9bd8d5fa
...
@@ -69,24 +69,26 @@ def write_ansible_k8s_files(tosca_template_json, tmp_path):
...
@@ -69,24 +69,26 @@ def write_ansible_k8s_files(tosca_template_json, tmp_path):
i
=
0
i
=
0
tasks
=
[]
tasks
=
[]
for
services_def
in
services
:
for
services_def
in
services
:
task
=
{
'name'
:
'Create a Service object'
+
str
(
i
)}
k8s
=
{
'state'
:
'present'
,
'definition'
:
services_def
}
k8s
=
{
'state'
:
'present'
,
'definition'
:
services_def
}
task
=
{
'name'
:
'Create a Service object'
+
str
(
i
),
'become'
:
'yes'
,
'k8s'
:
k8s
}
task
[
'k8s'
]
=
k8s
i
+=
1
i
+=
1
tasks
.
append
(
task
)
tasks
.
append
(
task
)
i
=
0
i
=
0
tasks
=
[]
for
deployments_def
in
deployments
:
for
deployments_def
in
deployments
:
k8s
=
{
'state'
:
'present'
,
'definition'
:
services_def
}
task
=
{
'name'
:
'Create a deployment object'
+
str
(
i
)}
task
=
{
'name'
:
'Create a Service object'
+
str
(
i
),
'become'
:
'yes'
,
'k8s'
:
k8s
}
k8s
=
{
'state'
:
'present'
,
'definition'
:
deployments_def
}
task
[
'k8s'
]
=
k8s
i
+=
1
i
+=
1
tasks
.
append
(
task
)
tasks
.
append
(
task
)
ansible_playbook
=
{
'hosts'
:
'k8-master'
,
'tasks'
:
tasks
}
ansible_playbook
=
[]
plays
=
{
'hosts'
:
'k8-master'
,
'tasks'
:
tasks
}
ansible_playbook
.
append
(
plays
)
print
(
yaml
.
safe_dump
(
ansible_playbook
))
print
(
yaml
.
safe_dump
(
ansible_playbook
))
ansible_playbook_path
=
tmp_path
+
'/'
+
'k8s_playbook.yml'
ansible_playbook_path
=
tmp_path
+
'/'
+
'k8s_playbook.yml'
f
=
open
(
ansible_playbook_path
,
"w"
)
yaml
.
dump
(
yaml
.
safe_dump
(
ansible_playbook
),
f
)
f
.
close
()
with
open
(
ansible_playbook_path
,
'w'
)
as
file
:
documents
=
yaml
.
dump
(
ansible_playbook
,
file
)
return
ansible_playbook_path
return
ansible_playbook_path
drip-deployer/.idea/drip-deployer.iml
0 → 100644
View file @
9bd8d5fa
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$"
/>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
\ No newline at end of file
drip-deployer/.idea/inspectionProfiles/profiles_settings.xml
0 → 100644
View file @
9bd8d5fa
<component
name=
"InspectionProjectProfileManager"
>
<settings>
<option
name=
"USE_PROJECT_PROFILE"
value=
"false"
/>
<version
value=
"1.0"
/>
</settings>
</component>
\ No newline at end of file
drip-deployer/.idea/modules.xml
0 → 100644
View file @
9bd8d5fa
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/drip-deployer.iml"
filepath=
"$PROJECT_DIR$/.idea/drip-deployer.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
drip-deployer/.idea/vcs.xml
0 → 100644
View file @
9bd8d5fa
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$/.."
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
drip-deployer/.idea/workspace.xml
0 → 100644
View file @
9bd8d5fa
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"350a2cb3-d21f-4a78-bd8c-7614f85494cc"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/../deployer/__main__.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../deployer/__main__.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../deployer/service/ansible_service.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../deployer/service/ansible_service.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../deployer/service/k8s_service.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../deployer/service/k8s_service.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../provisioner/pom.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../provisioner/pom.xml"
afterDir=
"false"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
</component>
<component
name=
"Git.Settings"
>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$/.."
/>
</component>
<component
name=
"ProjectId"
id=
"1XDOwMpLrjLoOX7wa6ziawR8wDT"
/>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
/>
<component
name=
"ProjectViewState"
>
<option
name=
"hideEmptyMiddlePackages"
value=
"true"
/>
<option
name=
"showExcludedFiles"
value=
"true"
/>
<option
name=
"showLibraryContents"
value=
"true"
/>
</component>
<component
name=
"PropertiesComponent"
>
<property
name=
"RunOnceActivity.ShowReadmeOnStart"
value=
"true"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$/../deployer"
/>
</component>
<component
name=
"SvnConfiguration"
>
<configuration
/>
</component>
<component
name=
"TaskManager"
>
<task
active=
"true"
id=
"Default"
summary=
"Default task"
>
<changelist
id=
"350a2cb3-d21f-4a78-bd8c-7614f85494cc"
name=
"Default Changelist"
comment=
""
/>
<created>
1580577435383
</created>
<option
name=
"number"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1580577435383
</updated>
</task>
<servers
/>
</component>
<component
name=
"WindowStateProjectService"
>
<state
x=
"1043"
y=
"437"
width=
"530"
height=
"598"
key=
"FileChooserDialogImpl"
timestamp=
"1580577475090"
>
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
<state
x=
"1043"
y=
"437"
width=
"530"
height=
"598"
key=
"FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1580577475090"
/>
</component>
</project>
\ No newline at end of file
provisioner/nbactions.xml
View file @
9bd8d5fa
...
@@ -15,4 +15,18 @@
...
@@ -15,4 +15,18 @@
<jpda.listen>
true
</jpda.listen>
<jpda.listen>
true
</jpda.listen>
</properties>
</properties>
</action>
</action>
<action>
<actionName>
run
</actionName>
<packagings>
<packaging>
jar
</packaging>
</packagings>
<goals>
<goal>
process-classes
</goal>
<goal>
org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
</goal>
</goals>
<properties>
<exec.args>
-classpath %classpath nl.uva.sne.drip.provisioner.RPCServer
</exec.args>
<exec.executable>
java
</exec.executable>
</properties>
</action>
</actions>
</actions>
provisioner/pom.xml
View file @
9bd8d5fa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<parent>
<groupId>
nl.uva.sne.drip
</groupId>
<groupId>
nl.uva.sne.drip
</groupId>
<artifactId>
drip
</artifactId>
<artifactId>
conf
</artifactId>
<version>
3.0.0
</version>
<version>
3.0.0
</version>
</parent>
</parent>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment