@@ -209,7 +209,9 @@ def normalize_hostnames(ctx):
209209def download_cephadm (ctx , config , ref ):
210210 cluster_name = config ['cluster' ]
211211
212- if 'cephadm_binary_url' in config :
212+ if 'cephadm_from_container' in config :
213+ _fetch_cephadm_from_container (ctx , config )
214+ elif 'cephadm_binary_url' in config :
213215 url = config ['cephadm_binary_url' ]
214216 _download_cephadm (ctx , url )
215217 elif config .get ('cephadm_mode' ) != 'cephadm-package' :
@@ -232,6 +234,36 @@ def download_cephadm(ctx, config, ref):
232234 _rm_cephadm (ctx )
233235
234236
237+ def _fetch_cephadm_from_container (ctx , config ):
238+ image = config ['image' ]
239+ cengine = 'podman'
240+ try :
241+ log .info ("Testing if podman is available" )
242+ ctx .cluster .run (args = ['sudo' , cengine , '--help' ])
243+ except CommandFailedError :
244+ log .info ("Failed to find podman. Using docker" )
245+ cengine = 'docker'
246+
247+ ctx .cluster .run (args = ['sudo' , cengine , 'pull' , image ])
248+ ctx .cluster .run (args = [
249+ 'sudo' , cengine , 'run' , '--rm' , '--entrypoint=cat' , image , '/usr/sbin/cephadm' ,
250+ run .Raw ('>' ),
251+ ctx .cephadm ,
252+ ])
253+
254+ # sanity-check the resulting file and set executable bit
255+ cephadm_file_size = '$(stat -c%s {})' .format (ctx .cephadm )
256+ ctx .cluster .run (
257+ args = [
258+ 'test' , '-s' , ctx .cephadm ,
259+ run .Raw ('&&' ),
260+ 'test' , run .Raw (cephadm_file_size ), "-gt" , run .Raw ('1000' ),
261+ run .Raw ('&&' ),
262+ 'chmod' , '+x' , ctx .cephadm ,
263+ ],
264+ )
265+
266+
235267def _fetch_cephadm_from_rpm (ctx ):
236268 log .info ("Copying cephadm installed from an RPM package" )
237269 # cephadm already installed from redhat.install task
0 commit comments