2727 state:
2828 description:
2929 - Indicate desired state for cluster resource.
30- - The state V(cleanup) has been added in community.general 11.3.0.
31- choices: [present, absent, enabled, disabled, cleanup]
30+ - The states V(cleanup) and V(cloned) have been added in community.general 11.3.0.
31+ - If O(state=cloned) or O(state=present), you can set O(resource_clone_ids) and O(resource_clone_meta) to determine exactly what and how to clone.
32+ choices: [present, absent, cloned, enabled, disabled, cleanup]
3233 default: present
3334 type: str
3435 name:
3536 description:
36- - Specify the resource name to create.
37+ - Specify the resource name to create or clone to .
3738 - This is required if O(state=present), O(state=absent), O(state=enabled), or O(state=disabled).
3839 type: str
3940 resource_type:
9596 - Options to associate with resource action.
9697 type: list
9798 elements: str
99+ resource_clone_ids:
100+ description:
101+ - List of clone resource IDs to clone from.
102+ type: list
103+ elements: str
104+ version_added: 11.3.0
105+ resource_clone_meta:
106+ description:
107+ - List of metadata to associate with clone resource.
108+ type: list
109+ elements: str
110+ version_added: 11.3.0
98111 wait:
99112 description:
100113 - Timeout period for polling the resource creation.
@@ -142,7 +155,7 @@ class PacemakerResource(StateModuleHelper):
142155 module = dict (
143156 argument_spec = dict (
144157 state = dict (type = 'str' , default = 'present' , choices = [
145- 'present' , 'absent' , 'enabled' , 'disabled' , 'cleanup' ]),
158+ 'present' , 'absent' , 'cloned' , ' enabled' , 'disabled' , 'cleanup' ]),
146159 name = dict (type = 'str' ),
147160 resource_type = dict (type = 'dict' , options = dict (
148161 resource_name = dict (type = 'str' ),
@@ -159,6 +172,8 @@ class PacemakerResource(StateModuleHelper):
159172 argument_action = dict (type = 'str' , choices = ['clone' , 'master' , 'group' , 'promotable' ]),
160173 argument_option = dict (type = 'list' , elements = 'str' ),
161174 )),
175+ resource_clone_ids = dict (type = 'list' , elements = 'str' ),
176+ resource_clone_meta = dict (type = 'list' , elements = 'str' ),
162177 wait = dict (type = 'int' , default = 300 ),
163178 ),
164179 required_if = [
@@ -194,17 +209,30 @@ def _get(self):
194209 ('out' , result [1 ] if result [1 ] != "" else None ),
195210 ('err' , result [2 ])])
196211
212+ def fmt_as_stack_argument (self , value , arg ):
213+ if value is not None :
214+ return [x for k in value for x in (arg , k )]
215+
197216 def state_absent (self ):
198217 force = get_pacemaker_maintenance_mode (self .runner )
199218 with self .runner ('cli_action state name force' , output_process = self ._process_command_output (True , "does not exist" ), check_mode_skip = True ) as ctx :
200219 ctx .run (cli_action = 'resource' , force = force )
201220
202221 def state_present (self ):
203222 with self .runner (
204- 'cli_action state name resource_type resource_option resource_operation resource_meta resource_argument wait' ,
223+ 'cli_action state name resource_type resource_option resource_operation resource_meta resource_argument '
224+ 'resource_clone_ids resource_clone_meta wait' ,
205225 output_process = self ._process_command_output (not get_pacemaker_maintenance_mode (self .runner ), "already exists" ),
206226 check_mode_skip = True ) as ctx :
207- ctx .run (cli_action = 'resource' )
227+ ctx .run (cli_action = 'resource' , resource_clone_ids = self .fmt_as_stack_argument (self .module .params ["resource_clone_ids" ], "clone" ))
228+
229+ def state_cloned (self ):
230+ with self .runner (
231+ 'cli_action state name resource_clone_ids resource_clone_meta wait' ,
232+ output_process = self ._process_command_output (
233+ not get_pacemaker_maintenance_mode (self .runner ),
234+ "already a clone resource" ), check_mode_skip = True ) as ctx :
235+ ctx .run (cli_action = 'resource' , resource_clone_meta = self .fmt_as_stack_argument (self .module .params ["resource_clone_meta" ], "meta" ))
208236
209237 def state_enabled (self ):
210238 with self .runner ('cli_action state name' , output_process = self ._process_command_output (True , "Starting" ), check_mode_skip = True ) as ctx :
0 commit comments