3030 - Hypercore version update to be installed on the cluster.
3131 type: str
3232 required: true
33+ force_update:
34+ description:
35+ - Upgrade the HyperCore cluster to the requested version,
36+ even if requested version is not listed under available versions of the HyperCore cluster.
37+ type: bool
38+ default: false
3339notes:
3440 - C(check_mode) is not supported.
3541"""
5157 type: dict
5258 contains:
5359 uuid:
54- description: Unique identifier in format major_version.minor_version.revision.build_id
60+ description: Unique identifier in format major_version.minor_version.revision.build_id.
5561 type: str
5662 sample: 9.2.11.210763
5763 description:
58- description: Human-readable name for the update
64+ description: |
65+ Human-readable name for the update.
66+ Empty if I(force_update=true).
5967 type: str
6068 sample: 9.2.11 General Availability
6169 change_log:
62- description: Description of all changes that are in this update, in HTML format
70+ description: |
71+ Description of all changes that are in this update, in HTML format.
72+ Empty if I(force_update=true).
6373 type: str
6474 sample: ...Please allow between 20-40 minutes per node for the update to complete...
6575 build_id:
7989 type: int
8090 sample: 11
8191 timestamp:
82- description: Unix timestamp when the update was released
92+ description: |
93+ Unix timestamp when the update was released.
94+ Value of 0 is returned if I(force_update=true).
8395 type: int
8496 sample: 0
8597"""
@@ -99,7 +111,8 @@ def run(
99111 module : AnsibleModule , rest_client : RestClient
100112) -> Tuple [bool , Optional [TypedUpdateToAnsible ], Dict [Any , Any ]]:
101113 cluster = Cluster .get (rest_client )
102- if cluster .icos_version == module .params ["icos_version" ]:
114+ new_icos_version = module .params ["icos_version" ]
115+ if cluster .icos_version == new_icos_version :
103116 return (
104117 False ,
105118 None ,
@@ -108,14 +121,33 @@ def run(
108121 after = dict (icos_version = cluster .icos_version ),
109122 ),
110123 )
111- update = Update .get (rest_client , module .params ["icos_version" ], must_exist = True )
112- update .apply (rest_client ) # type: ignore
124+ update = None
125+ if module .params ["force_update" ]:
126+ if len (new_icos_version .split ("." )) != 4 :
127+ msg = f"HyperCore version must be in format 'major_version.minor_version.revision.build_id' - value { new_icos_version } is not valid."
128+ raise errors .InvalidModuleParam (msg )
129+ update = Update (
130+ uuid = new_icos_version ,
131+ description = "" ,
132+ change_log = "" ,
133+ build_id = new_icos_version .split ("." )[3 ],
134+ major_version = new_icos_version .split ("." )[0 ],
135+ minor_version = new_icos_version .split ("." )[1 ],
136+ revision = new_icos_version .split ("." )[2 ],
137+ timestamp = 0 ,
138+ )
139+ else :
140+ # check the requested version is listed under available versions
141+ update = Update .get (rest_client , new_icos_version , must_exist = True )
142+ if not isinstance (update , Update ):
143+ raise AssertionError (f"update is not of type Update" ) # mypy helper
144+ Update .apply_update (rest_client , new_icos_version )
113145 return (
114146 True ,
115- update .to_ansible (), # type: ignore
147+ update .to_ansible (),
116148 dict (
117149 before = dict (icos_version = cluster .icos_version ),
118- after = dict (icos_version = update . uuid ), # type: ignore
150+ after = dict (icos_version = new_icos_version ),
119151 ),
120152 )
121153
@@ -126,6 +158,7 @@ def main() -> None:
126158 argument_spec = dict (
127159 arguments .get_spec ("cluster_instance" ),
128160 icos_version = dict (type = "str" , required = True ),
161+ force_update = dict (type = "bool" , default = False ),
129162 ),
130163 )
131164
0 commit comments