diff --git a/CHANGELOG.md b/CHANGELOG.md index 0422006..6314e4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ and this project adheres to - Report cluster settings in `firehpc status`. - Introduce `firehpc update` command to change cluster settings. - Introduce `firehpc bootstrap` command to create deployment environments. +- Add `firehpc {conf,deploy} --ansible-opts` option to append additional options + to `ansible-playbook` command (#44). - Integrated management of virtual environment to multiple versions of Ansible depending on targeted OS (#24). - Add PIP requirements files to populate _ansible-latest_ and _ansible-2.16_ @@ -84,6 +86,7 @@ and this project adheres to - Mention `firehpc bootstrap` command in manpage. - Mention cluster settings and `firehpc update` command in manpage. - Update README.md to mention bootstrap step in usage guide. + - Mention `--ansible-opts` option in manpage. - pkgs: Introduce tests extra package with dependencies required to run tests. ### Changed diff --git a/docs/man/firehpc.adoc b/docs/man/firehpc.adoc index 51da394..2dfbe63 100644 --- a/docs/man/firehpc.adoc +++ b/docs/man/firehpc.adoc @@ -119,6 +119,10 @@ This command accepts the following options: container and with a specific version of Slurm compiled to support emulation of arbitrary large number of fakes nodes. By default, value from cluster settings is used. + +[.cli-opt]#*--ansible-opts*# [.cli-optval]##_OPT …_##:: + Additional option to add to ansible-playbook command. Multiple options can be + given. -- [.cli-opt]#*deploy*#:: @@ -162,6 +166,10 @@ This command accepts the following options: Instead of randomly generating a new users directory, extract users directory from another existing cluster. This is useful to create the have the same user accounts on several clusters. + +[.cli-opt]#*--ansible-opts*# [.cli-optval]##_OPT …_##:: + Additional option to add to ansible-playbook command. Multiple options can be + given. -- + This command saves values of [.cli-opt]#*--db*#, [.cli-opt]#*--schema*#, diff --git a/firehpc/cluster.py b/firehpc/cluster.py index 02fbfa9..b0e62cf 100644 --- a/firehpc/cluster.py +++ b/firehpc/cluster.py @@ -117,6 +117,7 @@ def conf( tags: Optional[list[str]] = None, skip_tags: Optional[list[str]] = None, users_directory: Optional[UsersDirectory] = None, + ansible_opts: Optional[list[str]] = None, ) -> conf: if reinit: self.state.conf_clean() @@ -232,6 +233,9 @@ def insert_in_node_type(): f"{self.runtime_settings.ansible.args} --extra-vars @{self.state.extravars}" ) + if ansible_opts is not None and len(ansible_opts): + cmdline += f" {' '.join(ansible_opts)}" + if tags is not None and len(tags): cmdline += f" --tags {','.join(tags)}" diff --git a/firehpc/exec.py b/firehpc/exec.py index ce0d9e2..83ec715 100644 --- a/firehpc/exec.py +++ b/firehpc/exec.py @@ -107,6 +107,11 @@ def __init__(self): "--users", help="Extract users directory from another emulated cluster", ) + parser_deploy.add_argument( + "--ansible-opts", + help="Additional ansible-playbook options", + nargs="*", + ) parser_deploy.set_defaults(func=self._execute_deploy) # conf command @@ -149,6 +154,11 @@ def __init__(self): help="Enable Slurm emulator mode", action="store_true", ) + parser_conf.add_argument( + "--ansible-opts", + help="Additional ansible-playbook options", + nargs="*", + ) parser_conf.set_defaults(func=self._execute_conf) # restore command @@ -377,6 +387,7 @@ def _execute_deploy(self): db, playbooks=["bootstrap", "site"], users_directory=users_directory, + ansible_opts=self.args.ansible_opts, ) def _execute_conf(self): @@ -398,6 +409,7 @@ def _execute_conf(self): playbooks=playbooks, reinit=False, tags=self.args.tags, + ansible_opts=self.args.ansible_opts, ) def _execute_restore(self): diff --git a/lib/bash-completion/firehpc b/lib/bash-completion/firehpc index 648c991..f079a10 100644 --- a/lib/bash-completion/firehpc +++ b/lib/bash-completion/firehpc @@ -60,7 +60,7 @@ _firehpc_conf() { [CLUSTER]='--cluster' [DIR]='-c --custom' [FILE]='--db --schema' - [ARG]='--tags' + [ARG]='--tags --ansible-opts' ) if __contains_word "$prev" ${OPTS[CLUSTER]}; then comps=$( __firehpc_clusters_list ) @@ -104,7 +104,7 @@ _firehpc_deploy() { [OS]='--os' [DIR]='-c --custom' [FILE]='--db --schema' - [ARG]='--tags' + [ARG]='--ansible-opts' ) if __contains_word "$prev" ${OPTS[CLUSTER]}; then comps=$( __firehpc_clusters_list )