Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
052520a6
Verified
Commit
052520a6
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
add generic playbook execution method to the provisioning proxy service
parent
20c2c8c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!131
Move provisioning proxy steps to the new LSO endpoint
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gso/services/provisioning_proxy.py
+66
-0
66 additions, 0 deletions
gso/services/provisioning_proxy.py
with
66 additions
and
0 deletions
gso/services/provisioning_proxy.py
+
66
−
0
View file @
052520a6
...
...
@@ -7,6 +7,7 @@ import json
import
logging
from
functools
import
partial
from
http
import
HTTPStatus
from
typing
import
Any
import
requests
from
orchestrator
import
step
...
...
@@ -84,6 +85,71 @@ _send_put = partial(_send_request, CUDOperation.PUT)
_send_delete
=
partial
(
_send_request
,
CUDOperation
.
DELETE
)
def
execute_playbook
(
playbook_name
:
str
,
callback_route
:
str
,
inventory
:
dict
[
str
,
Any
],
extra_vars
:
dict
[
str
,
Any
]
)
->
None
:
"""
Execute a playbook remotely through the provisioning proxy.
When providing this method with an inventory, the format should be compatible with the Ansible YAML-based format.
For example, an inventory consisting of two hosts, which each a unique host variable assigned to them looks as
follows:
.. code-block:: json
"
inventory
"
: {
"
_meta
"
: {
"
vars
"
: {
"
host1.local
"
: {
"
foo
"
:
"
bar
"
},
"
host2.local
"
: {
"
key
"
:
"
value
"
}
}
},
"
all
"
: {
"
hosts
"
: {
"
host1.local
"
: null,
"
host2.local
"
: null
}
}
}
.. warning::
Note the fact that the collection of all hosts is a dictionary, and not a list of strings. Ansible expects each
host to be a key-value pair. The key is the :term:`FQDN` of a host, and the value always ``null``.
The extra vars can be a simple dict consisting of key-value pairs, for example:
.. code-block:: json
"
extra_vars
"
: {
"
dry_run
"
: true,
"
commit_comment
"
:
"
I am a robot!
"
,
"
verb
"
:
"
deploy
"
}
:param str playbook_name: Filename of the playbook that is to be executed. It must be present on the remote system
running the provisioning proxy, otherwise it will return an error.
:param str callback_route: The endpoint at which :term:`GSO` expects a callback to continue the workflow executing
this step.
:param dict[str, Any] inventory: An inventory of machines at which the playbook is targeted. Must be in
YAML-compatible format.
:param dict[str, Any] extra_vars: Any extra variables that the playbook relies on. This can include a subscription
object, a boolean value indicating a dry run, a commit comment, etc.
"""
parameters
=
{
"
playbook_name
"
:
playbook_name
,
"
inventory
"
:
inventory
,
"
extra_vars
"
:
extra_vars
}
_send_post
(
"
playbook
"
,
parameters
,
callback_route
)
def
provision_router
(
subscription
:
RouterProvisioning
,
process_id
:
UUIDstr
,
...
...
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