@ -177,7 +177,7 @@ options:
- List of dictionaries describing the service configs .
- Every item must be a dictionary exposing the keys config_id , config_name , filename , uid ( defaults to 0 ) , gid ( defaults to 0 ) , mode ( defaults to 0o444 )
- Maps docker service - - config option .
default : [ ]
default : null
networks :
required : false
default : [ ]
@ -189,8 +189,9 @@ options:
required : false
description :
- List of dictionaries describing the service published ports .
- Every item must be a dictionary exposing the keys published_port , target_port , protocol ( defaults to ' tcp ' ) , mode < ingress | host > , default to ingress .
- Every item must be a dictionary exposing the keys published_port , target_port , protocol ( defaults to ' tcp ' )
- Only used with api_version > = 1.25
- If api_version > = 1.32 the dictionaries can contain the attribute ' mode ' set to ' ingress ' or ' host ' ( default ' ingress ' ) .
replicas :
required : false
default : - 1
@ -262,13 +263,11 @@ options:
- Maps to docker service - - update - max - failure - ratio
update_order :
required : false
default : stop- first
default : null
description :
- Specifies the order of operations when rolling out an updated task .
- Maps to docker service - - update - order
choices :
- stop - first
- start - first
- Requires docker api version > = 1.29
user :
required : false
default : root
@ -496,7 +495,7 @@ class DockerService(DockerBaseClass):
self . mode = " replicated "
self . user = " root "
self . mounts = [ ]
self . configs = [ ]
self . configs = None
self . secrets = [ ]
self . constraints = [ ]
self . networks = [ ]
@ -513,7 +512,7 @@ class DockerService(DockerBaseClass):
self . update_failure_action = " continue "
self . update_monitor = 5000000000
self . update_max_failure_ratio = 0.00
self . update_order = " stop-first "
self . update_order = None
def get_facts ( self ) :
return {
@ -608,13 +607,13 @@ class DockerService(DockerBaseClass):
for param_p in ap [ ' publish ' ] :
service_p = { }
service_p [ ' protocol ' ] = param_p . get ( ' protocol ' , ' tcp ' )
service_p [ ' mode ' ] = param_p . get ( ' mode ' , ' ingress ' )
service_p [ ' mode ' ] = param_p . get ( ' mode ' , None )
service_p [ ' published_port ' ] = int ( param_p [ ' published_port ' ] )
service_p [ ' target_port ' ] = int ( param_p [ ' target_port ' ] )
if service_p [ ' protocol ' ] not in [ ' tcp ' , ' udp ' ] :
raise ValueError ( " got publish.protocol ' %s ' , valid values: ' tcp ' , ' udp ' " %
service_p [ ' protocol ' ] )
if service_p [ ' mode ' ] not in [ ' ingress ' , ' host ' ] :
if service_p [ ' mode ' ] not in [ None , ' ingress ' , ' host ' ] :
raise ValueError ( " got publish.mode ' %s ' , valid values: ' ingress ' , ' host ' " %
service_p [ ' mode ' ] )
s . publish . append ( service_p )
@ -627,6 +626,8 @@ class DockerService(DockerBaseClass):
service_m [ ' target ' ] = param_m [ ' target ' ]
s . mounts . append ( service_m )
s . configs = None
if ap [ ' configs ' ] :
s . configs = [ ]
for param_m in ap [ ' configs ' ] :
service_c = { }
@ -754,6 +755,8 @@ class DockerService(DockerBaseClass):
read_only = mount_config [ ' readonly ' ] )
)
configs = None
if self . configs :
configs = [ ]
for config_config in self . configs :
configs . append (
@ -766,6 +769,7 @@ class DockerService(DockerBaseClass):
mode = config_config . get ( ' mode ' )
)
)
secrets = [ ]
for secret_config in self . secrets :
secrets . append (
@ -846,7 +850,10 @@ class DockerService(DockerBaseClass):
ports = { }
for port in self . publish :
if port [ ' mode ' ] :
ports [ int ( port [ ' published_port ' ] ) ] = ( int ( port [ ' target_port ' ] ) , port [ ' protocol ' ] , port [ ' mode ' ] )
else :
ports [ int ( port [ ' published_port ' ] ) ] = ( int ( port [ ' target_port ' ] ) , port [ ' protocol ' ] )
endpoint_spec = types . EndpointSpec ( mode = self . endpoint_mode , ports = ports )
return update_policy , task_template , networks , endpoint_spec , mode , self . labels
@ -883,6 +890,8 @@ class DockerServiceManager():
ds . update_failure_action = update_config_data [ ' FailureAction ' ]
ds . update_monitor = update_config_data [ ' Monitor ' ]
ds . update_max_failure_ratio = update_config_data [ ' MaxFailureRatio ' ]
if ' Order ' in update_config_data :
ds . update_order = update_config_data [ ' Order ' ]
dns_config = task_template_data [ ' ContainerSpec ' ] . get ( ' DNSConfig ' , None )
@ -913,7 +922,7 @@ class DockerServiceManager():
for port in raw_data_endpoint_spec . get ( ' Ports ' , [ ] ) :
ds . publish . append ( {
' protocol ' : port [ ' Protocol ' ] ,
' mode ' : port . get ( ' PublishMode ' , ' ingress ' ) ,
' mode ' : port . get ( ' PublishMode ' , None ) ,
' published_port ' : int ( port [ ' PublishedPort ' ] ) ,
' target_port ' : int ( port [ ' TargetPort ' ] ) } )
@ -1019,7 +1028,8 @@ class DockerServiceManager():
{ ' param ' : ' hostname ' , ' attribute ' : ' hostname ' , ' min_version ' : ' 1.25 ' } ,
{ ' param ' : ' tty ' , ' attribute ' : ' tty ' , ' min_version ' : ' 1.25 ' } ,
{ ' param ' : ' secrets ' , ' attribute ' : ' secrets ' , ' min_version ' : ' 1.25 ' } ,
{ ' param ' : ' configs ' , ' attribute ' : ' configs ' , ' min_version ' : ' 1.30 ' } ]
{ ' param ' : ' configs ' , ' attribute ' : ' configs ' , ' min_version ' : ' 1.30 ' } ,
{ ' param ' : ' update_order ' , ' attribute ' : ' update_order ' , ' min_version ' : ' 1.29 ' } ]
params = self . client . module . params
empty_service = DockerService ( )
for pv in parameters_versions :
@ -1113,7 +1123,7 @@ def main():
image = dict ( type = ' str ' ) ,
state = dict ( default = " present " , choices = [ ' present ' , ' absent ' ] ) ,
mounts = dict ( default = [ ] , type = ' list ' ) ,
configs = dict ( default = [ ] , type = ' list ' ) ,
configs = dict ( default = None , type = ' list ' ) ,
secrets = dict ( default = [ ] , type = ' list ' ) ,
networks = dict ( default = [ ] , type = ' list ' ) ,
args = dict ( default = [ ] , type = ' list ' ) ,
@ -1146,7 +1156,7 @@ def main():
update_failure_action = dict ( default = ' continue ' , choices = [ ' continue ' , ' pause ' ] ) ,
update_monitor = dict ( default = 5000000000 , type = ' int ' ) ,
update_max_failure_ratio = dict ( default = 0 , type = ' float ' ) ,
update_order = dict ( default = ' stop-first ' , choices = [ ' stop-first ' , ' start-first ' ] ) ,
update_order = dict ( default = None , type = ' string ' ) ,
user = dict ( default = ' root ' ) )
required_if = [
( ' state ' , ' present ' , [ ' image ' ] )