cli_installer.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. # TODO: Temporarily disabled due to importing old code into openshift-ansible
  2. # repo. We will work on these over time.
  3. # pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,no-value-for-parameter
  4. import click
  5. import os
  6. import re
  7. import sys
  8. from ooinstall import openshift_ansible
  9. from ooinstall import OOConfig
  10. from ooinstall.oo_config import Host
  11. from ooinstall.variants import find_variant, get_variant_version_combos
  12. DEFAULT_ANSIBLE_CONFIG = '/usr/share/atomic-openshift-utils/ansible.cfg'
  13. DEFAULT_PLAYBOOK_DIR = '/usr/share/ansible/openshift-ansible/'
  14. def validate_ansible_dir(path):
  15. if not path:
  16. raise click.BadParameter('An ansible path must be provided')
  17. return path
  18. # if not os.path.exists(path)):
  19. # raise click.BadParameter("Path \"{}\" doesn't exist".format(path))
  20. def is_valid_hostname(hostname):
  21. if not hostname or len(hostname) > 255:
  22. return False
  23. if hostname[-1] == ".":
  24. hostname = hostname[:-1] # strip exactly one dot from the right, if present
  25. allowed = re.compile(r"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
  26. return all(allowed.match(x) for x in hostname.split("."))
  27. def validate_prompt_hostname(hostname):
  28. if '' == hostname or is_valid_hostname(hostname):
  29. return hostname
  30. raise click.BadParameter('"{}" appears to be an invalid hostname. ' \
  31. 'Please double-check this value i' \
  32. 'and re-enter it.'.format(hostname))
  33. def get_ansible_ssh_user():
  34. click.clear()
  35. message = """
  36. This installation process will involve connecting to remote hosts via ssh. Any
  37. account may be used however if a non-root account is used it must have
  38. passwordless sudo access.
  39. """
  40. click.echo(message)
  41. return click.prompt('User for ssh access', default='root')
  42. def list_hosts(hosts):
  43. hosts_idx = range(len(hosts))
  44. for idx in hosts_idx:
  45. click.echo(' {}: {}'.format(idx, hosts[idx]))
  46. def delete_hosts(hosts):
  47. while True:
  48. list_hosts(hosts)
  49. del_idx = click.prompt('Select host to delete, y/Y to confirm, ' \
  50. 'or n/N to add more hosts', default='n')
  51. try:
  52. del_idx = int(del_idx)
  53. hosts.remove(hosts[del_idx])
  54. except IndexError:
  55. click.echo("\"{}\" doesn't match any hosts listed.".format(del_idx))
  56. except ValueError:
  57. try:
  58. response = del_idx.lower()
  59. if response in ['y', 'n']:
  60. return hosts, response
  61. click.echo("\"{}\" doesn't coorespond to any valid input.".format(del_idx))
  62. except AttributeError:
  63. click.echo("\"{}\" doesn't coorespond to any valid input.".format(del_idx))
  64. return hosts, None
  65. def collect_hosts(master_set=False):
  66. """
  67. Collect host information from user. This will later be filled in using
  68. ansible.
  69. Returns: a list of host information collected from the user
  70. """
  71. click.clear()
  72. click.echo('***Host Configuration***')
  73. message = """
  74. The OpenShift Master serves the API and web console. It also coordinates the
  75. jobs that have to run across the environment. It can even run the datastore.
  76. For wizard based installations the database will be embedded. It's possible to
  77. change this later using etcd from Red Hat Enterprise Linux 7.
  78. Any Masters configured as part of this installation process will also be
  79. configured as Nodes. This is so that the Master will be able to proxy to Pods
  80. from the API. By default this Node will be unscheduleable but this can be changed
  81. after installation with 'oadm manage-node'.
  82. The OpenShift Node provides the runtime environments for containers. It will
  83. host the required services to be managed by the Master.
  84. http://docs.openshift.com/enterprise/latest/architecture/infrastructure_components/kubernetes_infrastructure.html#master
  85. http://docs.openshift.com/enterprise/latest/architecture/infrastructure_components/kubernetes_infrastructure.html#node
  86. """
  87. click.echo(message)
  88. hosts = []
  89. more_hosts = True
  90. while more_hosts:
  91. host_props = {}
  92. hostname_or_ip = click.prompt('Enter hostname or IP address:',
  93. default='',
  94. value_proc=validate_prompt_hostname)
  95. host_props['connect_to'] = hostname_or_ip
  96. if not master_set:
  97. is_master = click.confirm('Will this host be an OpenShift Master?')
  98. host_props['master'] = is_master
  99. master_set = True
  100. host_props['node'] = True
  101. #TODO: Reenable this option once container installs are out of tech preview
  102. #rpm_or_container = click.prompt('Will this host be RPM or Container based (rpm/container)?',
  103. # type=click.Choice(['rpm', 'container']),
  104. # default='rpm')
  105. #if rpm_or_container == 'container':
  106. # host_props['containerized'] = True
  107. #else:
  108. # host_props['containerized'] = False
  109. host_props['containerized'] = False
  110. host = Host(**host_props)
  111. hosts.append(host)
  112. more_hosts = click.confirm('Do you want to add additional hosts?')
  113. return hosts
  114. def confirm_hosts_facts(oo_cfg, callback_facts):
  115. hosts = oo_cfg.hosts
  116. click.clear()
  117. message = """
  118. A list of the facts gathered from the provided hosts follows. Because it is
  119. often the case that the hostname for a system inside the cluster is different
  120. from the hostname that is resolveable from command line or web clients
  121. these settings cannot be validated automatically.
  122. For some cloud providers the installer is able to gather metadata exposed in
  123. the instance so reasonable defaults will be provided.
  124. Plese confirm that they are correct before moving forward.
  125. """
  126. notes = """
  127. Format:
  128. connect_to,IP,public IP,hostname,public hostname
  129. Notes:
  130. * The installation host is the hostname from the installer's perspective.
  131. * The IP of the host should be the internal IP of the instance.
  132. * The public IP should be the externally accessible IP associated with the instance
  133. * The hostname should resolve to the internal IP from the instances
  134. themselves.
  135. * The public hostname should resolve to the external ip from hosts outside of
  136. the cloud.
  137. """
  138. # For testing purposes we need to click.echo only once, so build up
  139. # the message:
  140. output = message
  141. default_facts_lines = []
  142. default_facts = {}
  143. for h in hosts:
  144. default_facts[h.connect_to] = {}
  145. h.ip = callback_facts[h.connect_to]["common"]["ip"]
  146. h.public_ip = callback_facts[h.connect_to]["common"]["public_ip"]
  147. h.hostname = callback_facts[h.connect_to]["common"]["hostname"]
  148. h.public_hostname = callback_facts[h.connect_to]["common"]["public_hostname"]
  149. default_facts_lines.append(",".join([h.connect_to,
  150. h.ip,
  151. h.public_ip,
  152. h.hostname,
  153. h.public_hostname]))
  154. output = "%s\n%s" % (output, ",".join([h.connect_to,
  155. h.ip,
  156. h.public_ip,
  157. h.hostname,
  158. h.public_hostname]))
  159. output = "%s\n%s" % (output, notes)
  160. click.echo(output)
  161. facts_confirmed = click.confirm("Do the above facts look correct?")
  162. if not facts_confirmed:
  163. message = """
  164. Edit %s with the desired values and run `atomic-openshift-installer --unattended install` to restart the install.
  165. """ % oo_cfg.config_path
  166. click.echo(message)
  167. # Make sure we actually write out the config file.
  168. oo_cfg.save_to_disk()
  169. sys.exit(0)
  170. return default_facts
  171. def get_variant_and_version():
  172. message = "\nWhich variant would you like to install?\n\n"
  173. i = 1
  174. combos = get_variant_version_combos()
  175. for (variant, version) in combos:
  176. message = "%s\n(%s) %s %s" % (message, i, variant.description,
  177. version.name)
  178. i = i + 1
  179. click.echo(message)
  180. response = click.prompt("Choose a variant from above: ", default=1)
  181. product, version = combos[response - 1]
  182. return product, version
  183. def confirm_continue(message):
  184. click.echo(message)
  185. click.confirm("Are you ready to continue?", default=False, abort=True)
  186. return
  187. def error_if_missing_info(oo_cfg):
  188. missing_info = False
  189. if not oo_cfg.hosts:
  190. missing_info = True
  191. click.echo('For unattended installs, hosts must be specified on the '
  192. 'command line or in the config file: %s' % oo_cfg.config_path)
  193. sys.exit(1)
  194. if 'ansible_ssh_user' not in oo_cfg.settings:
  195. click.echo("Must specify ansible_ssh_user in configuration file.")
  196. sys.exit(1)
  197. # Lookup a variant based on the key we were given:
  198. if not oo_cfg.settings['variant']:
  199. click.echo("No variant specified in configuration file.")
  200. sys.exit(1)
  201. ver = None
  202. if 'variant_version' in oo_cfg.settings:
  203. ver = oo_cfg.settings['variant_version']
  204. variant, version = find_variant(oo_cfg.settings['variant'], version=ver)
  205. if variant is None or version is None:
  206. err_variant_name = oo_cfg.settings['variant']
  207. if ver:
  208. err_variant_name = "%s %s" % (err_variant_name, ver)
  209. click.echo("%s is not an installable variant." % err_variant_name)
  210. sys.exit(1)
  211. oo_cfg.settings['variant_version'] = version.name
  212. missing_facts = oo_cfg.calc_missing_facts()
  213. if len(missing_facts) > 0:
  214. missing_info = True
  215. click.echo('For unattended installs, facts must be provided for all masters/nodes:')
  216. for host in missing_facts:
  217. click.echo('Host "%s" missing facts: %s' % (host, ", ".join(missing_facts[host])))
  218. if missing_info:
  219. sys.exit(1)
  220. def get_missing_info_from_user(oo_cfg):
  221. """ Prompts the user for any information missing from the given configuration. """
  222. click.clear()
  223. message = """
  224. Welcome to the OpenShift Enterprise 3 installation.
  225. Please confirm that following prerequisites have been met:
  226. * All systems where OpenShift will be installed are running Red Hat Enterprise
  227. Linux 7.
  228. * All systems are properly subscribed to the required OpenShift Enterprise 3
  229. repositories.
  230. * All systems have run docker-storage-setup (part of the Red Hat docker RPM).
  231. * All systems have working DNS that resolves not only from the perspective of
  232. the installer but also from within the cluster.
  233. When the process completes you will have a default configuration for Masters
  234. and Nodes. For ongoing environment maintenance it's recommended that the
  235. official Ansible playbooks be used.
  236. For more information on installation prerequisites please see:
  237. https://docs.openshift.com/enterprise/latest/admin_guide/install/prerequisites.html
  238. """
  239. confirm_continue(message)
  240. click.clear()
  241. if oo_cfg.settings.get('ansible_ssh_user', '') == '':
  242. oo_cfg.settings['ansible_ssh_user'] = get_ansible_ssh_user()
  243. click.clear()
  244. if not oo_cfg.hosts:
  245. oo_cfg.hosts = collect_hosts()
  246. click.clear()
  247. if oo_cfg.settings.get('variant', '') == '':
  248. variant, version = get_variant_and_version()
  249. oo_cfg.settings['variant'] = variant.name
  250. oo_cfg.settings['variant_version'] = version.name
  251. click.clear()
  252. return oo_cfg
  253. def collect_new_nodes():
  254. click.clear()
  255. click.echo('***New Node Configuration***')
  256. message = """
  257. Add new nodes here
  258. """
  259. click.echo(message)
  260. return collect_hosts(True)
  261. def get_installed_hosts(hosts, callback_facts):
  262. installed_hosts = []
  263. for host in hosts:
  264. if(host.connect_to in callback_facts.keys()
  265. and 'common' in callback_facts[host.connect_to].keys()
  266. and callback_facts[host.connect_to]['common'].get('version', '')
  267. and callback_facts[host.connect_to]['common'].get('version', '') != 'None'):
  268. installed_hosts.append(host)
  269. return installed_hosts
  270. # pylint: disable=too-many-branches
  271. # This pylint error will be corrected shortly in separate PR.
  272. def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force, verbose):
  273. # Copy the list of existing hosts so we can remove any already installed nodes.
  274. hosts_to_run_on = list(oo_cfg.hosts)
  275. # Check if master or nodes already have something installed
  276. installed_hosts = get_installed_hosts(oo_cfg.hosts, callback_facts)
  277. if len(installed_hosts) > 0:
  278. click.echo('Installed environment detected.')
  279. # This check has to happen before we start removing hosts later in this method
  280. if not force:
  281. if not unattended:
  282. click.echo('By default the installer only adds new nodes to an installed environment.')
  283. response = click.prompt('Do you want to (1) only add additional nodes or ' \
  284. '(2) reinstall the existing hosts ' \
  285. 'potentially erasing any custom changes?',
  286. type=int)
  287. # TODO: this should be reworked with error handling.
  288. # Click can certainly do this for us.
  289. # This should be refactored as soon as we add a 3rd option.
  290. if response == 1:
  291. force = False
  292. if response == 2:
  293. force = True
  294. # present a message listing already installed hosts and remove hosts if needed
  295. for host in installed_hosts:
  296. if host.master:
  297. click.echo("{} is already an OpenShift Master".format(host))
  298. # Masters stay in the list, we need to run against them when adding
  299. # new nodes.
  300. elif host.node:
  301. click.echo("{} is already an OpenShift Node".format(host))
  302. # force is only used for reinstalls so we don't want to remove
  303. # anything.
  304. if not force:
  305. hosts_to_run_on.remove(host)
  306. # Handle the cases where we know about uninstalled systems
  307. new_hosts = set(hosts_to_run_on) - set(installed_hosts)
  308. if len(new_hosts) > 0:
  309. for new_host in new_hosts:
  310. click.echo("{} is currently uninstalled".format(new_host))
  311. # Fall through
  312. click.echo('Adding additional nodes...')
  313. else:
  314. if unattended:
  315. if not force:
  316. click.echo('Installed environment detected and no additional nodes specified: ' \
  317. 'aborting. If you want a fresh install, use ' \
  318. '`atomic-openshift-installer install --force`')
  319. sys.exit(1)
  320. else:
  321. if not force:
  322. new_nodes = collect_new_nodes()
  323. hosts_to_run_on.extend(new_nodes)
  324. oo_cfg.hosts.extend(new_nodes)
  325. openshift_ansible.set_config(oo_cfg)
  326. click.echo('Gathering information from hosts...')
  327. callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts, verbose)
  328. if error:
  329. click.echo("There was a problem fetching the required information. " \
  330. "See {} for details.".format(oo_cfg.settings['ansible_log_path']))
  331. sys.exit(1)
  332. else:
  333. pass # proceeding as normal should do a clean install
  334. return hosts_to_run_on, callback_facts
  335. @click.group()
  336. @click.pass_context
  337. @click.option('--unattended', '-u', is_flag=True, default=False)
  338. @click.option('--configuration', '-c',
  339. type=click.Path(file_okay=True,
  340. dir_okay=False,
  341. writable=True,
  342. readable=True),
  343. default=None)
  344. @click.option('--ansible-playbook-directory',
  345. '-a',
  346. type=click.Path(exists=True,
  347. file_okay=False,
  348. dir_okay=True,
  349. readable=True),
  350. # callback=validate_ansible_dir,
  351. default=DEFAULT_PLAYBOOK_DIR,
  352. envvar='OO_ANSIBLE_PLAYBOOK_DIRECTORY')
  353. @click.option('--ansible-config',
  354. type=click.Path(file_okay=True,
  355. dir_okay=False,
  356. writable=True,
  357. readable=True),
  358. default=None)
  359. @click.option('--ansible-log-path',
  360. type=click.Path(file_okay=True,
  361. dir_okay=False,
  362. writable=True,
  363. readable=True),
  364. default="/tmp/ansible.log")
  365. @click.option('-v', '--verbose',
  366. is_flag=True, default=False)
  367. #pylint: disable=too-many-arguments
  368. # Main CLI entrypoint, not much we can do about too many arguments.
  369. def cli(ctx, unattended, configuration, ansible_playbook_directory, ansible_config, ansible_log_path, verbose):
  370. """
  371. atomic-openshift-installer makes the process for installing OSE or AEP easier by interactively gathering the data needed to run on each host.
  372. It can also be run in unattended mode if provided with a configuration file.
  373. Further reading: https://docs.openshift.com/enterprise/latest/install_config/install/quick_install.html
  374. """
  375. ctx.obj = {}
  376. ctx.obj['unattended'] = unattended
  377. ctx.obj['configuration'] = configuration
  378. ctx.obj['ansible_config'] = ansible_config
  379. ctx.obj['ansible_log_path'] = ansible_log_path
  380. ctx.obj['verbose'] = verbose
  381. oo_cfg = OOConfig(ctx.obj['configuration'])
  382. # If no playbook dir on the CLI, check the config:
  383. if not ansible_playbook_directory:
  384. ansible_playbook_directory = oo_cfg.settings.get('ansible_playbook_directory', '')
  385. # If still no playbook dir, check for the default location:
  386. if not ansible_playbook_directory and os.path.exists(DEFAULT_PLAYBOOK_DIR):
  387. ansible_playbook_directory = DEFAULT_PLAYBOOK_DIR
  388. validate_ansible_dir(ansible_playbook_directory)
  389. oo_cfg.settings['ansible_playbook_directory'] = ansible_playbook_directory
  390. oo_cfg.ansible_playbook_directory = ansible_playbook_directory
  391. ctx.obj['ansible_playbook_directory'] = ansible_playbook_directory
  392. if ctx.obj['ansible_config']:
  393. oo_cfg.settings['ansible_config'] = ctx.obj['ansible_config']
  394. elif os.path.exists(DEFAULT_ANSIBLE_CONFIG):
  395. # If we're installed by RPM this file should exist and we can use it as our default:
  396. oo_cfg.settings['ansible_config'] = DEFAULT_ANSIBLE_CONFIG
  397. oo_cfg.settings['ansible_log_path'] = ctx.obj['ansible_log_path']
  398. ctx.obj['oo_cfg'] = oo_cfg
  399. openshift_ansible.set_config(oo_cfg)
  400. @click.command()
  401. @click.pass_context
  402. def uninstall(ctx):
  403. oo_cfg = ctx.obj['oo_cfg']
  404. verbose = ctx.obj['verbose']
  405. if len(oo_cfg.hosts) == 0:
  406. click.echo("No hosts defined in: %s" % oo_cfg['configuration'])
  407. sys.exit(1)
  408. click.echo("OpenShift will be uninstalled from the following hosts:\n")
  409. if not ctx.obj['unattended']:
  410. # Prompt interactively to confirm:
  411. for host in oo_cfg.hosts:
  412. click.echo(" * %s" % host.connect_to)
  413. proceed = click.confirm("\nDo you wish to proceed?")
  414. if not proceed:
  415. click.echo("Uninstall cancelled.")
  416. sys.exit(0)
  417. openshift_ansible.run_uninstall_playbook(verbose)
  418. @click.command()
  419. @click.pass_context
  420. def upgrade(ctx):
  421. oo_cfg = ctx.obj['oo_cfg']
  422. verbose = ctx.obj['verbose']
  423. if len(oo_cfg.hosts) == 0:
  424. click.echo("No hosts defined in: %s" % oo_cfg.config_path)
  425. sys.exit(1)
  426. # Update config to reflect the version we're targetting, we'll write
  427. # to disk once ansible completes successfully, not before.
  428. old_variant = oo_cfg.settings['variant']
  429. old_version = oo_cfg.settings['variant_version']
  430. if oo_cfg.settings['variant'] == 'enterprise':
  431. oo_cfg.settings['variant'] = 'openshift-enterprise'
  432. version = find_variant(oo_cfg.settings['variant'])[1]
  433. oo_cfg.settings['variant_version'] = version.name
  434. click.echo("Openshift will be upgraded from %s %s to %s %s on the following hosts:\n" % (
  435. old_variant, old_version, oo_cfg.settings['variant'],
  436. oo_cfg.settings['variant_version']))
  437. for host in oo_cfg.hosts:
  438. click.echo(" * %s" % host.connect_to)
  439. if not ctx.obj['unattended']:
  440. # Prompt interactively to confirm:
  441. proceed = click.confirm("\nDo you wish to proceed?")
  442. if not proceed:
  443. click.echo("Upgrade cancelled.")
  444. sys.exit(0)
  445. retcode = openshift_ansible.run_upgrade_playbook(verbose)
  446. if retcode > 0:
  447. click.echo("Errors encountered during upgrade, please check %s." %
  448. oo_cfg.settings['ansible_log_path'])
  449. else:
  450. oo_cfg.save_to_disk()
  451. click.echo("Upgrade completed! Rebooting all hosts is recommended.")
  452. @click.command()
  453. @click.option('--force', '-f', is_flag=True, default=False)
  454. @click.pass_context
  455. def install(ctx, force):
  456. oo_cfg = ctx.obj['oo_cfg']
  457. verbose = ctx.obj['verbose']
  458. if ctx.obj['unattended']:
  459. error_if_missing_info(oo_cfg)
  460. else:
  461. oo_cfg = get_missing_info_from_user(oo_cfg)
  462. click.echo('Gathering information from hosts...')
  463. callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts,
  464. verbose)
  465. if error:
  466. click.echo("There was a problem fetching the required information. " \
  467. "Please see {} for details.".format(oo_cfg.settings['ansible_log_path']))
  468. sys.exit(1)
  469. hosts_to_run_on, callback_facts = get_hosts_to_run_on(
  470. oo_cfg, callback_facts, ctx.obj['unattended'], force, verbose)
  471. click.echo('Writing config to: %s' % oo_cfg.config_path)
  472. # We already verified this is not the case for unattended installs, so this can
  473. # only trigger for live CLI users:
  474. # TODO: if there are *new* nodes and this is a live install, we may need the user
  475. # to confirm the settings for new nodes. Look into this once we're distinguishing
  476. # between new and pre-existing nodes.
  477. if len(oo_cfg.calc_missing_facts()) > 0:
  478. confirm_hosts_facts(oo_cfg, callback_facts)
  479. oo_cfg.save_to_disk()
  480. click.echo('Ready to run installation process.')
  481. message = """
  482. If changes are needed to the values recorded by the installer please update {}.
  483. """.format(oo_cfg.config_path)
  484. if not ctx.obj['unattended']:
  485. confirm_continue(message)
  486. error = openshift_ansible.run_main_playbook(oo_cfg.hosts,
  487. hosts_to_run_on, verbose)
  488. if error:
  489. # The bootstrap script will print out the log location.
  490. message = """
  491. An error was detected. After resolving the problem please relaunch the
  492. installation process.
  493. """
  494. click.echo(message)
  495. sys.exit(1)
  496. else:
  497. message = """
  498. The installation was successful!
  499. If this is your first time installing please take a look at the Administrator
  500. Guide for advanced options related to routing, storage, authentication and much
  501. more:
  502. http://docs.openshift.com/enterprise/latest/admin_guide/overview.html
  503. """
  504. click.echo(message)
  505. click.pause()
  506. cli.add_command(install)
  507. cli.add_command(upgrade)
  508. cli.add_command(uninstall)
  509. if __name__ == '__main__':
  510. # This is expected behaviour for context passing with click library:
  511. # pylint: disable=unexpected-keyword-arg
  512. cli(obj={})