Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
1c318fa3
Commit
1c318fa3
authored
Jun 20, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'exit_json' of
https://github.com/psa/ansible
into psa-exit_json
parents
06e0e1f7
7d28f30b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
15 deletions
+45
-15
library/cloud/ec2_asg
+18
-0
library/cloud/ec2_metric_alarm
+22
-3
library/cloud/ec2_scaling_policy
+5
-12
No files found.
library/cloud/ec2_asg
View file @
1c318fa3
...
...
@@ -217,6 +217,24 @@ def create_autoscaling_group(connection, module):
except
BotoServerError
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
result
=
as_groups
[
0
]
module
.
exit_json
(
changed
=
changed
,
name
=
result
.
name
,
autoscaling_group_arn
=
result
.
autoscaling_group_arn
,
availability_zones
=
result
.
availability_zones
,
created_time
=
str
(
result
.
created_time
),
default_cooldown
=
result
.
default_cooldown
,
health_check_period
=
result
.
health_check_period
,
health_check_type
=
result
.
health_check_type
,
instance_id
=
result
.
instance_id
,
instances
=
[
instance
.
instance_id
for
instance
in
result
.
instances
],
launch_config_name
=
result
.
launch_config_name
,
load_balancers
=
result
.
load_balancers
,
min_size
=
result
.
min_size
,
max_size
=
result
.
max_size
,
placement_group
=
result
.
placement_group
,
tags
=
result
.
tags
,
termination_policies
=
result
.
termination_policies
,
vpc_zone_identifier
=
result
.
vpc_zone_identifier
)
def
delete_autoscaling_group
(
connection
,
module
):
group_name
=
module
.
params
.
get
(
'name'
)
...
...
library/cloud/ec2_metric_alarm
View file @
1c318fa3
...
...
@@ -167,7 +167,8 @@ def create_metric_alarm(connection, module):
)
try
:
connection
.
create_alarm
(
alm
)
module
.
exit_json
(
changed
=
True
)
changed
=
True
alarms
=
connection
.
describe_alarms
(
alarm_names
=
[
name
])
except
BotoServerError
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
...
...
@@ -203,10 +204,28 @@ def create_metric_alarm(connection, module):
try
:
if
changed
:
connection
.
create_alarm
(
alarm
)
module
.
exit_json
(
changed
=
changed
)
except
BotoServerError
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
result
=
alarms
[
0
]
module
.
exit_json
(
changed
=
changed
,
name
=
result
.
name
,
actions_enabled
=
result
.
actions_enabled
,
alarm_actions
=
result
.
alarm_actions
,
alarm_arn
=
result
.
alarm_arn
,
comparison
=
result
.
comparison
,
description
=
result
.
description
,
dimensions
=
result
.
dimensions
,
evaluation_periods
=
result
.
evaluation_periods
,
insufficient_data_actions
=
result
.
insufficient_data_actions
,
last_updated
=
result
.
last_updated
,
metric
=
result
.
metric
,
namespace
=
result
.
namespace
,
ok_actions
=
result
.
ok_actions
,
period
=
result
.
period
,
state_reason
=
result
.
state_reason
,
state_value
=
result
.
state_value
,
statistic
=
result
.
statistic
,
threshold
=
result
.
threshold
,
unit
=
result
.
unit
)
def
delete_metric_alarm
(
connection
,
module
):
name
=
module
.
params
.
get
(
'name'
)
...
...
library/cloud/ec2_scaling_policy
View file @
1c318fa3
...
...
@@ -99,16 +99,17 @@ def create_scaling_policy(connection, module):
policy
=
scalingPolicies
[
0
]
changed
=
False
#min_adjustment_step attribute is only relevant if the adjustment_type
#is set to percentage change in capacity, so it is a special case
#
min_adjustment_step attribute is only relevant if the adjustment_type
#
is set to percentage change in capacity, so it is a special case
if
getattr
(
policy
,
'adjustment_type'
)
==
'PercentChangeInCapacity'
:
if
getattr
(
policy
,
'min_adjustment_step'
)
!=
module
.
params
.
get
(
'min_adjustment_step'
):
changed
=
True
#set the min adjustment step incase the user decided to change their adjustment type to percentage
# set the min adjustment step incase the user decided to change their
# adjustment type to percentage
setattr
(
policy
,
'min_adjustment_step'
,
module
.
params
.
get
(
'min_adjustment_step'
))
#check the remaining attributes
#
check the remaining attributes
for
attr
in
(
'adjustment_type'
,
'scaling_adjustment'
,
'cooldown'
):
if
getattr
(
policy
,
attr
)
!=
module
.
params
.
get
(
attr
):
changed
=
True
...
...
@@ -119,8 +120,6 @@ def create_scaling_policy(connection, module):
connection
.
create_scaling_policy
(
policy
)
policy
=
connection
.
get_all_policies
(
policy_names
=
[
sp_name
])[
0
]
module
.
exit_json
(
changed
=
changed
,
name
=
policy
.
name
,
arn
=
policy
.
policy_arn
,
as_name
=
policy
.
as_name
,
scaling_adjustment
=
policy
.
scaling_adjustment
,
cooldown
=
policy
.
cooldown
,
adjustment_type
=
policy
.
adjustment_type
,
min_adjustment_step
=
policy
.
min_adjustment_step
)
policy
=
connection
.
get_all_policies
(
policy_names
=
[
sp_name
])[
0
]
module
.
exit_json
(
changed
=
changed
,
name
=
policy
.
name
,
arn
=
policy
.
policy_arn
,
as_name
=
policy
.
as_name
,
scaling_adjustment
=
policy
.
scaling_adjustment
,
cooldown
=
policy
.
cooldown
,
adjustment_type
=
policy
.
adjustment_type
,
min_adjustment_step
=
policy
.
min_adjustment_step
)
except
BotoServerError
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
...
...
@@ -176,9 +175,3 @@ def main():
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment