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
c1f8cfaa
Commit
c1f8cfaa
authored
5 years ago
by
Attila Farkas
Browse files
Options
Downloads
Patches
Plain Diff
generate inventory files
parent
95e6a88f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Resolve Refactoring
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
create.py
+5
-5
5 additions, 5 deletions
create.py
modules/ansible_generator.py
+16
-1
16 additions, 1 deletion
modules/ansible_generator.py
templates/inventory
+10
-0
10 additions, 0 deletions
templates/inventory
with
31 additions
and
6 deletions
create.py
+
5
−
5
View file @
c1f8cfaa
...
@@ -59,8 +59,8 @@ except Exception:
...
@@ -59,8 +59,8 @@ except Exception:
sys
.
exit
(
1
)
sys
.
exit
(
1
)
"""
Generating ansible playbooks.
"""
"""
Generating ansible playbooks.
"""
try
:
#
try:
generate_playbooks
(
device_definitions
,
flags
)
generate_playbooks
(
device_definitions
,
flags
)
except
Exception
:
#
except Exception:
print
(
"
Playbooks could not be created.
"
)
#
print("Playbooks could not be created.")
sys
.
exit
(
1
)
#
sys.exit(1)
This diff is collapsed.
Click to expand it.
modules/ansible_generator.py
+
16
−
1
View file @
c1f8cfaa
from
modules.file_manager
import
load_template
,
generate_file
def
_create_inventory
(
input_definitions
):
def
_create_inventory
(
input_definitions
):
"""
Creates an inventory file with host groups.
"""
"""
Creates an inventory file with host groups.
"""
host_names
=
[]
for
host
in
input_definitions
[
"
hosts
"
]:
host_names
.
append
(
host
[
"
name
"
])
router_names
=
[]
for
router
in
input_definitions
[
"
routers
"
]:
router_names
.
append
(
router
[
"
name
"
])
inventory_template
=
load_template
(
"
inventory
"
)
output
=
inventory_template
.
render
(
hosts
=
host_names
,
routers
=
router_names
)
generate_file
(
"
provisioning/inventory.ini
"
,
output
)
generate_file
(
"
base_provisioning/inventory.ini
"
,
output
)
def
generate_playbooks
(
input_definitions
,
flags
):
def
generate_playbooks
(
input_definitions
,
flags
):
"""
Generates ansible playbooks.
"""
Generates ansible playbooks.
...
@@ -9,4 +24,4 @@ def generate_playbooks(input_definitions, flags):
...
@@ -9,4 +24,4 @@ def generate_playbooks(input_definitions, flags):
:param flags: command line input flags
:param flags: command line input flags
"""
"""
_create_inventory
(
input_definitions
)
_create_inventory
(
input_definitions
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/inventory
0 → 100644
+
10
−
0
View file @
c1f8cfaa
[hosts]
{% for host in hosts %}
{{ host }}
{% endfor %}
[routers]
{% for router in routers %}
{{ router }}
{% endfor %}
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