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
dbbb2bc2
Commit
dbbb2bc2
authored
Jun 19, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'origin/devel' into devel
parents
3060e66e
e1abda42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
25 deletions
+64
-25
library/cloud/ec2
+24
-8
library/files/ini_file
+40
-17
No files found.
library/cloud/ec2
View file @
dbbb2bc2
...
@@ -36,7 +36,7 @@ options:
...
@@ -36,7 +36,7 @@ options:
aliases: []
aliases: []
group:
group:
description:
description:
- security group to use with the instance
- security group
(or list of groups)
to use with the instance
required: false
required: false
default: null
default: null
aliases: []
aliases: []
...
@@ -190,6 +190,18 @@ EXAMPLES = '''
...
@@ -190,6 +190,18 @@ EXAMPLES = '''
count: 5
count: 5
instance_tags: '{"db":"postgres"}' monitoring=yes'
instance_tags: '{"db":"postgres"}' monitoring=yes'
# Multiple groups example
local_action:
module: ec2
keypair: mykey
group: [databases, internal-services, sshable, and-so-forth]
instance_type: m1.large
image: ami-6e649707
wait: yes
wait_timeout: 500
count: 5
instance_tags: '{"db":"postgres"}' monitoring=yes'
# VPC example
# VPC example
- local_action:
- local_action:
module: ec2
module: ec2
...
@@ -215,7 +227,7 @@ def main():
...
@@ -215,7 +227,7 @@ def main():
argument_spec
=
dict
(
argument_spec
=
dict
(
key_name
=
dict
(
required
=
True
,
aliases
=
[
'keypair'
]),
key_name
=
dict
(
required
=
True
,
aliases
=
[
'keypair'
]),
id
=
dict
(),
id
=
dict
(),
group
=
dict
(),
group
=
dict
(
type
=
'list'
),
group_id
=
dict
(),
group_id
=
dict
(),
region
=
dict
(
choices
=
[
'eu-west-1'
,
'sa-east-1'
,
'us-east-1'
,
'ap-northeast-1'
,
'us-west-2'
,
'us-west-1'
,
'ap-southeast-1'
,
'ap-southeast-2'
]),
region
=
dict
(
choices
=
[
'eu-west-1'
,
'sa-east-1'
,
'us-east-1'
,
'ap-northeast-1'
,
'us-west-2'
,
'us-west-1'
,
'ap-southeast-1'
,
'ap-southeast-2'
]),
zone
=
dict
(),
zone
=
dict
(),
...
@@ -294,14 +306,18 @@ def main():
...
@@ -294,14 +306,18 @@ def main():
# Here we try to lookup the group id from the security group name - if group is set.
# Here we try to lookup the group id from the security group name - if group is set.
if
group_name
:
if
group_name
:
grp_details
=
ec2
.
get_all_security_groups
()
grp_details
=
ec2
.
get_all_security_groups
()
for
grp
in
grp_details
:
if
type
(
group_name
)
==
list
:
if
str
(
group_name
)
in
str
(
grp
):
group_id
=
list
(
filter
(
lambda
grp
:
str
(
grp
.
id
)
if
str
(
tmp
)
in
str
(
grp
)
else
None
,
grp_details
)
for
tmp
in
group_name
)
group_id
=
str
(
grp
.
id
)
elif
type
(
group_name
)
==
str
:
for
grp
in
grp_details
:
if
str
(
group_name
)
in
str
(
grp
):
group_id
=
[
str
(
grp
.
id
)]
group_name
=
[
group_name
]
# Now we try to lookup the group id testing if group exists.
# Now we try to lookup the group id testing if group exists.
elif
group_id
:
elif
group_id
:
grp_details
=
ec2
.
get_all_security_groups
(
group_ids
=
group_id
)
grp_details
=
ec2
.
get_all_security_groups
(
group_ids
=
group_id
)
grp_item
=
grp_details
[
0
]
grp_item
=
grp_details
[
0
]
group_name
=
grp_item
.
name
group_name
=
[
grp_item
.
name
]
except
boto
.
exception
.
NoAuthHandlerFound
,
e
:
except
boto
.
exception
.
NoAuthHandlerFound
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
module
.
fail_json
(
msg
=
str
(
e
))
...
@@ -338,9 +354,9 @@ def main():
...
@@ -338,9 +354,9 @@ def main():
'user_data'
:
user_data
}
'user_data'
:
user_data
}
if
vpc_subnet_id
:
if
vpc_subnet_id
:
params
[
'security_group_ids'
]
=
[
group_id
]
params
[
'security_group_ids'
]
=
group_id
else
:
else
:
params
[
'security_groups'
]
=
[
group_name
]
params
[
'security_groups'
]
=
group_name
res
=
ec2
.
run_instances
(
**
params
)
res
=
ec2
.
run_instances
(
**
params
)
except
boto
.
exception
.
BotoServerError
,
e
:
except
boto
.
exception
.
BotoServerError
,
e
:
...
...
library/files/ini_file
View file @
dbbb2bc2
...
@@ -108,12 +108,21 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
...
@@ -108,12 +108,21 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
changed
=
True
changed
=
True
else
:
else
:
if
option
is
not
None
:
if
option
is
not
None
:
try
:
if
type
(
option
)
==
str
:
if
cp
.
get
(
section
,
option
):
try
:
cp
.
remove_option
(
section
,
option
)
if
cp
.
get
(
section
,
option
):
changed
=
True
cp
.
remove_option
(
section
,
option
)
except
:
changed
=
True
pass
except
:
pass
else
:
for
o
in
option
:
try
:
if
cp
.
get
(
section
,
o
):
cp
.
remove_option
(
section
,
o
)
changed
=
True
except
:
pass
if
state
==
'present'
:
if
state
==
'present'
:
if
cp
.
has_section
(
section
)
==
False
:
if
cp
.
has_section
(
section
)
==
False
:
...
@@ -124,17 +133,31 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
...
@@ -124,17 +133,31 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
changed
=
True
changed
=
True
if
option
is
not
None
and
value
is
not
None
:
if
option
is
not
None
and
value
is
not
None
:
try
:
olist
=
[]
oldvalue
=
cp
.
get
(
section
,
option
)
vlist
=
[]
if
str
(
value
)
!=
str
(
oldvalue
):
if
type
(
option
)
==
str
and
type
(
value
)
==
str
:
olist
.
append
(
option
)
vlist
.
append
(
value
)
else
:
olist
=
list
(
option
)
vlist
=
list
(
value
)
if
len
(
olist
)
!=
len
(
vlist
):
module
.
fail_json
(
msg
=
"Option and value lists must be of same lengths"
)
n
=
0
for
option
in
olist
:
value
=
vlist
[
n
]
n
=
n
+
1
try
:
oldvalue
=
cp
.
get
(
section
,
option
)
if
str
(
value
)
!=
str
(
oldvalue
):
cp
.
set
(
section
,
option
,
value
)
changed
=
True
except
ConfigParser
.
NoSectionError
:
cp
.
set
(
section
,
option
,
value
)
changed
=
True
except
ConfigParser
.
NoOptionError
:
cp
.
set
(
section
,
option
,
value
)
cp
.
set
(
section
,
option
,
value
)
changed
=
True
changed
=
True
except
ConfigParser
.
NoSectionError
:
cp
.
set
(
section
,
option
,
value
)
changed
=
True
except
ConfigParser
.
NoOptionError
:
cp
.
set
(
section
,
option
,
value
)
changed
=
True
if
changed
:
if
changed
:
if
backup
:
if
backup
:
...
@@ -157,8 +180,8 @@ def main():
...
@@ -157,8 +180,8 @@ def main():
argument_spec
=
dict
(
argument_spec
=
dict
(
dest
=
dict
(
required
=
True
),
dest
=
dict
(
required
=
True
),
section
=
dict
(
required
=
True
),
section
=
dict
(
required
=
True
),
option
=
dict
(
required
=
False
),
option
=
dict
(
required
=
False
,
type
=
'list'
),
value
=
dict
(
required
=
False
),
value
=
dict
(
required
=
False
,
type
=
'list'
),
backup
=
dict
(
default
=
'no'
,
type
=
'bool'
),
backup
=
dict
(
default
=
'no'
,
type
=
'bool'
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
])
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
])
),
),
...
...
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