Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cyber-sandbox-creator
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUNI-KYPO-CSC
cyber-sandbox-creator
Commits
86f0ff5a
Commit
86f0ff5a
authored
5 years ago
by
Attila Farkas
Browse files
Options
Downloads
Patches
Plain Diff
remove import_playbook
parent
bbeba0ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/file_generator.py
+7
-3
7 additions, 3 deletions
modules/file_generator.py
templates/playbook
+23
-2
23 additions, 2 deletions
templates/playbook
with
30 additions
and
5 deletions
modules/file_generator.py
+
7
−
3
View file @
86f0ff5a
...
...
@@ -55,11 +55,15 @@ def generate_vagrantfile(definitions):
print
(
"
Info: Vagrantfile successfully created.
"
)
def
_generate_playbook
():
def
_generate_playbook
(
definitions
):
"""
Generates the main playbook.
"""
host_map
=
create_host_map
(
definitions
[
"
net_mappings
"
],
definitions
[
"
router_mappings
"
],
definitions
[
"
hosts
"
])
network
=
create_network_map
(
definitions
[
"
net_mappings
"
],
definitions
[
"
router_mappings
"
])
template
=
_load_template
(
"
playbook
"
)
output
=
template
.
render
()
output
=
template
.
render
(
hosts
=
host_map
,
routers
=
network
)
try
:
os
.
mkdir
(
"
provisioning
"
)
...
...
@@ -124,7 +128,7 @@ def _generate_routers_role(definitions):
def
generate_ansible_files
(
device_definitions
):
"""
Generates files for ansible.
"""
_generate_playbook
()
_generate_playbook
(
device_definitions
)
_generate_device_configuration
(
device_definitions
)
_generate_hosts_role
(
device_definitions
)
_generate_routers_role
(
device_definitions
)
...
...
This diff is collapsed.
Click to expand it.
templates/playbook
+
23
−
2
View file @
86f0ff5a
---
# Main ansible play
ground
# Main ansible play
book
- import_playbook: device_configuration.yml
#- import_playbook: device_configuration.yml - for new version
- name: Configuring all hosts
hosts: {{ hosts|map(attribute='host_name')|unique|join(',') }}
become: yes
roles:
- hosts
{% for host in hosts %}
- name: Configuring host {{ host.host_name }}
hosts: {{ host.host_name }}
become: yes
tasks:
- name: Change default gateway
command: route add default gw {{ host.router_ip }} {{ host.interface }}
{% endfor %}
- name: Configuring all routers
hosts: {{ routers|map(attribute='router_name')|unique|join(',') }}
become: yes
roles:
- routers
# Write your custom configuration here:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment