ansible-pull, ansible-console - remove unused --list-hosts option

pull/84208/head
s-hertel 3 weeks ago
parent 157ef04b1e
commit 3166606a58

@ -1,3 +1,2 @@
minor_changes: minor_changes:
- > - ansible cli - add --flush-cache option for ad-hoc commands (https://github.com/ansible/ansible/issues/83749).
ansible, ansible-console, ansible-pull - add --flush-cache option (https://github.com/ansible/ansible/issues/83749).

@ -0,0 +1,3 @@
bugfixes:
- >
ansible-pull, ansible-console - remove ignored --list-hosts option.

@ -10,6 +10,7 @@ from __future__ import annotations
# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first # ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI from ansible.cli import CLI
import argparse
import atexit import atexit
import cmd import cmd
import getpass import getpass
@ -116,6 +117,9 @@ class ConsoleCLI(CLI, cmd.Cmd):
opt_help.add_runtask_options(self.parser) opt_help.add_runtask_options(self.parser)
opt_help.add_tasknoplay_options(self.parser) opt_help.add_tasknoplay_options(self.parser)
# remove unused default options
self.parser.add_argument('--list-hosts', help=argparse.SUPPRESS, action=opt_help.UnrecognizedArgument)
# options unique to shell # options unique to shell
self.parser.add_argument('pattern', help='host pattern', metavar='pattern', default='all', nargs='?') self.parser.add_argument('pattern', help='host pattern', metavar='pattern', default='all', nargs='?')
self.parser.add_argument('--step', dest='step', action='store_true', self.parser.add_argument('--step', dest='step', action='store_true',

@ -9,6 +9,7 @@ from __future__ import annotations
# ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first # ansible.cli needs to be imported first, to ensure the source bin/* scripts run that code first
from ansible.cli import CLI from ansible.cli import CLI
import argparse
import datetime import datetime
import os import os
import platform import platform
@ -93,6 +94,9 @@ class PullCLI(CLI):
self.parser.add_argument('args', help='Playbook(s)', metavar='playbook.yml', nargs='*') self.parser.add_argument('args', help='Playbook(s)', metavar='playbook.yml', nargs='*')
# remove unused default options
self.parser.add_argument('--list-hosts', help=argparse.SUPPRESS, action=opt_help.UnrecognizedArgument)
# options unique to pull # options unique to pull
self.parser.add_argument('--purge', default=False, action='store_true', help='purge checkout after playbook run') self.parser.add_argument('--purge', default=False, action='store_true', help='purge checkout after playbook run')
self.parser.add_argument('-o', '--only-if-changed', dest='ifchanged', default=False, action='store_true', self.parser.add_argument('-o', '--only-if-changed', dest='ifchanged', default=False, action='store_true',
@ -298,9 +302,6 @@ class PullCLI(CLI):
if context.CLIARGS['diff']: if context.CLIARGS['diff']:
cmd += ' -D' cmd += ' -D'
if context.CLIARGS['flush_cache']:
cmd += ' --flush-cache'
os.chdir(context.CLIARGS['dest']) os.chdir(context.CLIARGS['dest'])
# redo inventory options as new files might exist now # redo inventory options as new files might exist now

@ -1,5 +0,0 @@
- hosts: localhost
gather_facts: false
tasks:
- assert:
that: ansible_facts == {}

@ -64,6 +64,19 @@ function pass_tests_multi {
fi fi
} }
function pass_tests_unsupported_argument {
if [[ -z "$1" ]]; then
echo "Error: an argument is required."
exit 1
fi
local expected="ansible-pull: error: unrecognized arguments: ${1}"
if ! grep "${expected}" "${temp_log}"; then
echo "Did not fail as expected with: ${expected}"
exit 1
fi
}
export ANSIBLE_INVENTORY export ANSIBLE_INVENTORY
export ANSIBLE_HOST_PATTERN_MISMATCH export ANSIBLE_HOST_PATTERN_MISMATCH
@ -92,8 +105,6 @@ ANSIBLE_CONFIG='' ansible-pull -d "${pull_dir}" -U "${repo_dir}" conn_secret.yml
# fail if we try do delete /var/tmp # fail if we try do delete /var/tmp
ANSIBLE_CONFIG='' ansible-pull -d var/tmp -U "${repo_dir}" --purge "$@" ANSIBLE_CONFIG='' ansible-pull -d var/tmp -U "${repo_dir}" --purge "$@"
# test flushing the fact cache # test unsupported options
export ANSIBLE_CACHE_PLUGIN=jsonfile ANSIBLE_CACHE_PLUGIN_CONNECTION=./ ansible-pull -d "${pull_dir}" -U "${repo_dir}" --list-hosts "$@" multi_play_1.yml 2> >(tee "${temp_log}") || true
ansible-pull -d "${pull_dir}" -U "${repo_dir}" "$@" gather_facts.yml pass_tests_unsupported_argument --list-hosts
ansible-pull -d "${pull_dir}" -U "${repo_dir}" --flush-cache "$@" test_empty_facts.yml
unset ANSIBLE_CACHE_PLUGIN ANSIBLE_CACHE_PLUGIN_CONNECTION

Loading…
Cancel
Save