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:
- >
ansible, ansible-console, ansible-pull - add --flush-cache option (https://github.com/ansible/ansible/issues/83749).
- ansible cli - add --flush-cache option for ad-hoc commands (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
from ansible.cli import CLI
import argparse
import atexit
import cmd
import getpass
@ -116,6 +117,9 @@ class ConsoleCLI(CLI, cmd.Cmd):
opt_help.add_runtask_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
self.parser.add_argument('pattern', help='host pattern', metavar='pattern', default='all', nargs='?')
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
from ansible.cli import CLI
import argparse
import datetime
import os
import platform
@ -93,6 +94,9 @@ class PullCLI(CLI):
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
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',
@ -298,9 +302,6 @@ class PullCLI(CLI):
if context.CLIARGS['diff']:
cmd += ' -D'
if context.CLIARGS['flush_cache']:
cmd += ' --flush-cache'
os.chdir(context.CLIARGS['dest'])
# 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
}
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_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
ANSIBLE_CONFIG='' ansible-pull -d var/tmp -U "${repo_dir}" --purge "$@"
# test flushing the fact cache
export ANSIBLE_CACHE_PLUGIN=jsonfile ANSIBLE_CACHE_PLUGIN_CONNECTION=./
ansible-pull -d "${pull_dir}" -U "${repo_dir}" "$@" gather_facts.yml
ansible-pull -d "${pull_dir}" -U "${repo_dir}" --flush-cache "$@" test_empty_facts.yml
unset ANSIBLE_CACHE_PLUGIN ANSIBLE_CACHE_PLUGIN_CONNECTION
# test unsupported options
ansible-pull -d "${pull_dir}" -U "${repo_dir}" --list-hosts "$@" multi_play_1.yml 2> >(tee "${temp_log}") || true
pass_tests_unsupported_argument --list-hosts

Loading…
Cancel
Save