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
4ca78408
Commit
4ca78408
authored
May 21, 2014
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user_data and config_drive support
parent
6bc056e0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
4 deletions
+41
-4
library/cloud/rax
+41
-4
No files found.
library/cloud/rax
View file @
4ca78408
...
...
@@ -31,7 +31,18 @@ options:
created servers. Only applicable when used with the I(group) attribute
or meta key.
default: yes
choices:
- "yes"
- "no"
version_added: 1.5
config_drive:
description:
- Attach read-only configuration drive to server as label config-2
default: no
choices:
- "yes"
- "no"
version_added: 1.7
count:
description:
- number of instances to launch
...
...
@@ -55,6 +66,9 @@ options:
- Explicitly ensure an exact count of instances, used with
state=active/present
default: no
choices:
- "yes"
- "no"
version_added: 1.4
extra_client_args:
description:
...
...
@@ -119,6 +133,11 @@ options:
- present
- absent
default: present
user_data:
description:
- Data to be uploaded to the servers config drive. This option implies
I(config_drive)
version_added: 1.7
wait:
description:
- wait for the instance to be in state 'running' before returning
...
...
@@ -216,17 +235,29 @@ def server_to_dict(obj):
def
create
(
module
,
names
,
flavor
,
image
,
meta
,
key_name
,
files
,
wait
,
wait_timeout
,
disk_config
,
group
,
nics
,
extra_create_args
,
existing
=
[]):
extra_create_args
,
user_data
,
config_drive
,
existing
=
[]):
cs
=
pyrax
.
cloudservers
changed
=
False
if
user_data
:
config_drive
=
True
if
user_data
and
os
.
path
.
isfile
(
user_data
):
try
:
f
=
open
(
user_data
)
user_data
=
f
.
read
()
f
.
close
()
except
Exception
,
e
:
module
.
fail_json
(
msg
=
'Failed to load
%
s'
%
user_data
)
# Handle the file contents
for
rpath
in
files
.
keys
():
lpath
=
os
.
path
.
expanduser
(
files
[
rpath
])
try
:
fileobj
=
open
(
lpath
,
'r'
)
files
[
rpath
]
=
fileobj
.
read
()
fileobj
.
close
()
except
Exception
,
e
:
module
.
fail_json
(
msg
=
'Failed to load
%
s'
%
lpath
)
try
:
...
...
@@ -237,6 +268,8 @@ def create(module, names, flavor, image, meta, key_name, files,
key_name
=
key_name
,
files
=
files
,
nics
=
nics
,
disk_config
=
disk_config
,
config_drive
=
config_drive
,
userdata
=
user_data
,
**
extra_create_args
))
except
Exception
,
e
:
module
.
fail_json
(
msg
=
'
%
s'
%
e
.
message
)
...
...
@@ -382,7 +415,7 @@ def delete(module, instance_ids, wait, wait_timeout, kept=[]):
def
cloudservers
(
module
,
state
,
name
,
flavor
,
image
,
meta
,
key_name
,
files
,
wait
,
wait_timeout
,
disk_config
,
count
,
group
,
instance_ids
,
exact_count
,
networks
,
count_offset
,
auto_increment
,
extra_create_args
):
auto_increment
,
extra_create_args
,
user_data
,
config_drive
):
cs
=
pyrax
.
cloudservers
cnw
=
pyrax
.
cloud_networks
if
not
cnw
:
...
...
@@ -596,7 +629,7 @@ def cloudservers(module, state, name, flavor, image, meta, key_name, files,
create
(
module
,
names
,
flavor
,
image
,
meta
,
key_name
,
files
,
wait
,
wait_timeout
,
disk_config
,
group
,
nics
,
extra_create_args
,
existing
=
servers
)
user_data
,
config_drive
,
existing
=
servers
)
elif
state
==
'absent'
:
if
instance_ids
is
None
:
...
...
@@ -637,6 +670,7 @@ def main():
argument_spec
.
update
(
dict
(
auto_increment
=
dict
(
default
=
True
,
type
=
'bool'
),
config_drive
=
dict
(
default
=
False
,
type
=
'bool'
),
count
=
dict
(
default
=
1
,
type
=
'int'
),
count_offset
=
dict
(
default
=
1
,
type
=
'int'
),
disk_config
=
dict
(
choices
=
[
'auto'
,
'manual'
]),
...
...
@@ -654,6 +688,7 @@ def main():
networks
=
dict
(
type
=
'list'
,
default
=
[
'public'
,
'private'
]),
service
=
dict
(),
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
]),
user_data
=
dict
(
no_log
=
True
),
wait
=
dict
(
default
=
False
,
type
=
'bool'
),
wait_timeout
=
dict
(
default
=
300
),
)
...
...
@@ -675,6 +710,7 @@ def main():
'playbook pertaining to the "rax" module'
)
auto_increment
=
module
.
params
.
get
(
'auto_increment'
)
config_drive
=
module
.
params
.
get
(
'config_drive'
)
count
=
module
.
params
.
get
(
'count'
)
count_offset
=
module
.
params
.
get
(
'count_offset'
)
disk_config
=
module
.
params
.
get
(
'disk_config'
)
...
...
@@ -693,6 +729,7 @@ def main():
name
=
module
.
params
.
get
(
'name'
)
networks
=
module
.
params
.
get
(
'networks'
)
state
=
module
.
params
.
get
(
'state'
)
user_data
=
module
.
params
.
get
(
'user_data'
)
wait
=
module
.
params
.
get
(
'wait'
)
wait_timeout
=
int
(
module
.
params
.
get
(
'wait_timeout'
))
...
...
@@ -714,7 +751,7 @@ def main():
cloudservers
(
module
,
state
,
name
,
flavor
,
image
,
meta
,
key_name
,
files
,
wait
,
wait_timeout
,
disk_config
,
count
,
group
,
instance_ids
,
exact_count
,
networks
,
count_offset
,
auto_increment
,
extra_create_args
)
auto_increment
,
extra_create_args
,
user_data
,
config_drive
)
# import module snippets
...
...
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