Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
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
Container registry
Model registry
Operate
Environments
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
IML Open Source
Imldeployment
Commits
dc253a18
Commit
dc253a18
authored
3 years ago
by
hahn
Browse files
Options
Downloads
Patches
Plain Diff
task #4637 - awx plugin - handle empty vars
parent
98862ce8
No related branches found
No related tags found
1 merge request
!12
AWX - handling leerer AWX felder
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public_html/deployment/plugins/rollout/awx/rollout_awx.php
+29
-17
29 additions, 17 deletions
public_html/deployment/plugins/rollout/awx/rollout_awx.php
with
29 additions
and
17 deletions
public_html/deployment/plugins/rollout/awx/rollout_awx.php
+
29
−
17
View file @
dc253a18
...
@@ -17,7 +17,15 @@ class rollout_awx extends rollout_base {
...
@@ -17,7 +17,15 @@ class rollout_awx extends rollout_base {
// no specific checks needed ... always true
// no specific checks needed ... always true
return
true
;
return
true
;
}
}
/**
* check access to a deploy target
*/
public
function
checkConnectionToTarget
()
{
// do nothing ... always true
return
true
;
}
/**
/**
* make an http get request and return the response body
* make an http get request and return the response body
* it is called by _makeRequest
* it is called by _makeRequest
...
@@ -71,8 +79,6 @@ class rollout_awx extends rollout_base {
...
@@ -71,8 +79,6 @@ class rollout_awx extends rollout_base {
return
$aReturn
;
return
$aReturn
;
}
}
/**
/**
* get AWX inventories and return them as array for select box
* get AWX inventories and return them as array for select box
* [id] => array('value' => [ID], 'label' => [NAME] [ID])
* [id] => array('value' => [ID], 'label' => [NAME] [ID])
...
@@ -129,13 +135,6 @@ class rollout_awx extends rollout_base {
...
@@ -129,13 +135,6 @@ class rollout_awx extends rollout_base {
return
$aReturn
;
return
$aReturn
;
}
}
/**
* check access to a deploy target
*/
public
function
checkConnectionToTarget
()
{
// do nothing ... always true
return
true
;
}
/**
/**
* get array with commands to execute to deploy a package
* get array with commands to execute to deploy a package
...
@@ -146,17 +145,30 @@ class rollout_awx extends rollout_base {
...
@@ -146,17 +145,30 @@ class rollout_awx extends rollout_base {
public
function
getDeployCommands
(
$sPhase
){
public
function
getDeployCommands
(
$sPhase
){
$aReturn
=
array
();
$aReturn
=
array
();
$aConfig
=
$this
->
getConfig
(
$sPhase
);
$aConfig
=
$this
->
getConfig
(
$sPhase
);
// ----- Checks:
if
(
$aConfig
[
'extravars'
]){
$aTmp
=
json_decode
(
$aConfig
[
'extravars'
]);
if
(
!
$aTmp
||
!
count
(
$aTmp
)
){
$aReturn
[]
=
'echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '
.
$aConfig
[
'extravars'
]
.
'"'
;
}
$aConfig
[
'extravars'
]
=
json_decode
(
$aTmp
,
1
);
}
if
(
!
(
int
)
$aConfig
[
'inventory'
]){
if
(
!
(
int
)
$aConfig
[
'inventory'
]){
$aReturn
[]
=
'echo "ERROR: no inventory was given."; exit 1'
;
$aReturn
[]
=
'echo "ERROR: no inventory was given."; exit 1'
;
}
}
$sJson
=
'{
"inventory": "'
.
$aConfig
[
'inventory'
]
.
'",
$aBodyvars
=
array
();
"limit": "'
.
$aConfig
[
'limit'
]
.
'",
foreach
([
'inventory'
=>
'inventory'
,
'limit'
=>
'limit'
,
'job_tags'
=>
'tags'
,
'extra_vars'
=>
'extravars'
]
as
$sParam
=>
$sVarkey
){
"job_tags": "'
.
$aConfig
[
'tags'
]
.
'",
if
(
$aConfig
[
$sVarkey
])
{
"extra_vars": '
.
$aConfig
[
'extravars'
]
.
'
$aBodyvars
[
$sParam
]
=
$aConfig
[
$sVarkey
];
}'
;
}
}
$sAuth
=
(
$aConfig
[
'user'
]
?
'--user '
.
$aConfig
[
'user'
]
.
':'
.
$aConfig
[
'password'
]
:
''
);
$sAuth
=
(
$aConfig
[
'user'
]
?
'--user '
.
$aConfig
[
'user'
]
.
':'
.
$aConfig
[
'password'
]
:
''
);
$aReturn
[]
=
"curl -f -k -H 'Content-Type: application/json' -XPOST -d '"
.
$sJson
.
"'
$sAuth
"
.
$aConfig
[
'url'
]
.
"/job_templates/"
.
$aConfig
[
'jobtemplate'
]
.
"/launch/"
;
$aReturn
[]
=
"curl -f -k -H 'Content-Type: application/json' -XPOST -d '"
.
json_encode
(
$aBodyvars
,
JSON_PRETTY_PRINT
)
.
"'
$sAuth
"
.
$aConfig
[
'url'
]
.
"/job_templates/"
.
$aConfig
[
'jobtemplate'
]
.
"/launch/"
;
return
$aReturn
;
return
$aReturn
;
}
}
...
...
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