mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
Add PowerShell version of request_tower_configuration. From @nitzmahone.
This commit is contained in:
parent
abed41d390
commit
1bd6ffa3c9
@ -15,6 +15,7 @@ recursive-exclude awx/main/tests *
|
|||||||
recursive-exclude awx/ui/client *
|
recursive-exclude awx/ui/client *
|
||||||
recursive-exclude awx/settings local_settings.py*
|
recursive-exclude awx/settings local_settings.py*
|
||||||
include tools/scripts/request_tower_configuration.sh
|
include tools/scripts/request_tower_configuration.sh
|
||||||
|
include tools/scripts/request_tower_configuration.ps1
|
||||||
include tools/scripts/ansible-tower-service
|
include tools/scripts/ansible-tower-service
|
||||||
include tools/munin_monitors/*
|
include tools/munin_monitors/*
|
||||||
include tools/sosreport/*
|
include tools/sosreport/*
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -122,7 +122,7 @@ setup(
|
|||||||
("%s" % webconfig, ["config/awx-httpd-80.conf",
|
("%s" % webconfig, ["config/awx-httpd-80.conf",
|
||||||
"config/awx-httpd-443.conf",
|
"config/awx-httpd-443.conf",
|
||||||
"config/awx-munin.conf"]),
|
"config/awx-munin.conf"]),
|
||||||
("%s" % sharedir, ["tools/scripts/request_tower_configuration.sh",]),
|
("%s" % sharedir, ["tools/scripts/request_tower_configuration.sh","tools/scripts/request_tower_configuration.ps1"]),
|
||||||
("%s" % docdir, ["docs/licenses/*",]),
|
("%s" % docdir, ["docs/licenses/*",]),
|
||||||
("%s" % munin_plugin_path, ["tools/munin_monitors/tower_jobs",
|
("%s" % munin_plugin_path, ["tools/munin_monitors/tower_jobs",
|
||||||
"tools/munin_monitors/callbackr_alive",
|
"tools/munin_monitors/callbackr_alive",
|
||||||
|
|||||||
40
tools/scripts/request_tower_configuration.ps1
Normal file
40
tools/scripts/request_tower_configuration.ps1
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
Param(
|
||||||
|
[string]$tower_url,
|
||||||
|
[string]$host_config_key,
|
||||||
|
[string]$job_template_id
|
||||||
|
)
|
||||||
|
|
||||||
|
Set-StrictMode -Version 2
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
If(-not $tower_url -or -not $host_config_key -or -not $job_template_id)
|
||||||
|
{
|
||||||
|
Write-Host "Requests server configuration from Ansible Tower"
|
||||||
|
Write-Host "Usage: $($MyInvocation.MyCommand.Name) <server address>[:server port] <host config key> <job template id>"
|
||||||
|
Write-Host "Example: $($MyInvocation.MyCommand.Name) example.towerhost.net 44d7507f2ead49af5fca80aa18fd24bc 38"
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$retry_attempts = 10
|
||||||
|
$attempt = 0
|
||||||
|
|
||||||
|
$data = @{
|
||||||
|
host_config_key=$host_config_key
|
||||||
|
}
|
||||||
|
|
||||||
|
While ($attempt -lt $retry_attempts) {
|
||||||
|
Try {
|
||||||
|
$resp = Invoke-WebRequest -Method POST -Body $data -Uri http://$tower_url/api/v1/job_templates/$job_template_id/callback/ -UseBasicParsing
|
||||||
|
|
||||||
|
If($resp.StatusCode -eq 202) {
|
||||||
|
Exit 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
$ex = $_
|
||||||
|
$attempt++
|
||||||
|
Write-Host "$([int]$ex.Exception.Response.StatusCode) received... retrying in 1 minute (Attempt $attempt)"
|
||||||
|
}
|
||||||
|
Start-Sleep -Seconds 60
|
||||||
|
}
|
||||||
|
Exit 1
|
||||||
Loading…
x
Reference in New Issue
Block a user