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
7db78468
Commit
7db78468
authored
Mar 28, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6486 from discordianfish/docker-module-add-running
Rename present to running, add new present state
parents
351aea4c
32fa21c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
20 deletions
+30
-20
library/cloud/docker
+30
-20
No files found.
library/cloud/docker
View file @
7db78468
...
...
@@ -148,7 +148,7 @@ options:
- Set the state of the container
required: false
default: present
choices: [ "present", "stopped", "absent", "killed", "restarted" ]
choices: [ "present", "
running", "
stopped", "absent", "killed", "restarted" ]
aliases: []
privileged:
description:
...
...
@@ -636,7 +636,7 @@ def main():
env
=
dict
(
type
=
'list'
),
dns
=
dict
(),
detach
=
dict
(
default
=
True
,
type
=
'bool'
),
state
=
dict
(
default
=
'
present'
,
choices
=
[
'absent'
,
'present
'
,
'stopped'
,
'killed'
,
'restarted'
]),
state
=
dict
(
default
=
'
running'
,
choices
=
[
'absent'
,
'present'
,
'running
'
,
'stopped'
,
'killed'
,
'restarted'
]),
debug
=
dict
(
default
=
False
,
type
=
'bool'
),
privileged
=
dict
(
default
=
False
,
type
=
'bool'
),
stdin_open
=
dict
(
default
=
False
,
type
=
'bool'
),
...
...
@@ -668,25 +668,35 @@ def main():
changed
=
False
# start/stop containers
if
state
==
"present"
:
# make sure a container with `name`
is running
if
name
and
"/"
+
name
not
in
map
(
lambda
x
:
x
.
get
(
'Name'
),
running
_containers
):
if
state
in
[
"running"
,
"present"
]
:
# make sure a container with `name`
exists, if not create and start it
if
name
and
"/"
+
name
not
in
map
(
lambda
x
:
x
.
get
(
'Name'
),
deployed
_containers
):
containers
=
manager
.
create_containers
(
1
)
manager
.
start_containers
(
containers
)
# start more containers if we don't have enough
elif
delta
>
0
:
containers
=
manager
.
create_containers
(
delta
)
manager
.
start_containers
(
containers
)
# stop containers if we have too many
elif
delta
<
0
:
containers_to_stop
=
running_containers
[
0
:
abs
(
delta
)]
containers
=
manager
.
stop_containers
(
containers_to_stop
)
manager
.
remove_containers
(
containers_to_stop
)
facts
=
manager
.
get_running_containers
()
if
state
==
"present"
:
#otherwise it get (re)started later anyways..
manager
.
start_containers
(
containers
)
running_containers
=
manager
.
get_running_containers
()
deployed_containers
=
manager
.
get_deployed_containers
()
if
state
==
"running"
:
# make sure a container with `name` is running
if
name
and
"/"
+
name
not
in
map
(
lambda
x
:
x
.
get
(
'Name'
),
running_containers
):
manager
.
start_containers
(
deployed_containers
)
# start more containers if we don't have enough
elif
delta
>
0
:
containers
=
manager
.
create_containers
(
delta
)
manager
.
start_containers
(
containers
)
# stop containers if we have too many
elif
delta
<
0
:
containers_to_stop
=
running_containers
[
0
:
abs
(
delta
)]
containers
=
manager
.
stop_containers
(
containers_to_stop
)
manager
.
remove_containers
(
containers_to_stop
)
facts
=
manager
.
get_running_containers
()
else
:
acts
=
manager
.
get_deployed_containers
()
# stop and remove containers
elif
state
==
"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