diff options
author | Lee Garrett <lgarrett@rocketjump.eu> | 2022-09-13 16:39:18 +0200 |
---|---|---|
committer | Lee Garrett <lgarrett@rocketjump.eu> | 2022-09-13 16:39:18 +0200 |
commit | dfc95dfc10415e8ba138e2c042c39632c9251abb (patch) | |
tree | f0d4aac54ea7f6ef3ffb1b61d4a316fab0d2602c /bin | |
parent | 5883937d823fe68e35dbedf2a9d45ecaf6636470 (diff) | |
download | debian-ansible-core-dfc95dfc10415e8ba138e2c042c39632c9251abb.zip |
New upstream version 2.13.4
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ansible-connection | 18 | ||||
-rwxr-xr-x | bin/ansible-galaxy | 24 |
2 files changed, 28 insertions, 14 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection index f56e17cf..70cfad58 100755 --- a/bin/ansible-connection +++ b/bin/ansible-connection @@ -89,11 +89,11 @@ class ConnectionProcess(object): self.connection = None self._ansible_playbook_pid = ansible_playbook_pid - def start(self, variables): - try: - messages = list() - result = {} + def start(self, options): + messages = list() + result = {} + try: messages.append(('vvvv', 'control socket path is %s' % self.socket_path)) # If this is a relative path (~ gets expanded later) then plug the @@ -104,7 +104,7 @@ class ConnectionProcess(object): self.connection = connection_loader.get(self.play_context.connection, self.play_context, '/dev/null', task_uuid=self._task_uuid, ansible_playbook_pid=self._ansible_playbook_pid) try: - self.connection.set_options(var_options=variables) + self.connection.set_options(direct=options) except ConnectionError as exc: messages.append(('debug', to_text(exc))) raise ConnectionError('Unable to decode JSON from response set_options. See the debug log for more information.') @@ -244,11 +244,11 @@ def main(args=None): try: # read the play context data via stdin, which means depickling it - vars_data = read_stream(stdin) + opts_data = read_stream(stdin) init_data = read_stream(stdin) pc_data = pickle.loads(init_data, encoding='bytes') - variables = pickle.loads(vars_data, encoding='bytes') + options = pickle.loads(opts_data, encoding='bytes') play_context = PlayContext() play_context.deserialize(pc_data) @@ -286,7 +286,7 @@ def main(args=None): os.close(r) wfd = os.fdopen(w, 'w') process = ConnectionProcess(wfd, play_context, socket_path, original_path, task_uuid, ansible_playbook_pid) - process.start(variables) + process.start(options) except Exception: messages.append(('error', traceback.format_exc())) rc = 1 @@ -309,7 +309,7 @@ def main(args=None): messages.append(('vvvv', 'found existing local domain socket, using it!')) conn = Connection(socket_path) try: - conn.set_options(var_options=variables) + conn.set_options(direct=options) except ConnectionError as exc: messages.append(('debug', to_text(exc))) raise ConnectionError('Unable to decode JSON from response set_options. See the debug log for more information.') diff --git a/bin/ansible-galaxy b/bin/ansible-galaxy index 288318aa..5acaa6e4 100755 --- a/bin/ansible-galaxy +++ b/bin/ansible-galaxy @@ -487,7 +487,12 @@ class GalaxyCLI(CLI): else: install_parser.add_argument('-r', '--role-file', dest='requirements', help='A file containing a list of roles to be installed.') - if self._implicit_role and ('-r' in self._raw_args or '--role-file' in self._raw_args): + + r_re = re.compile(r'^(?<!-)-[a-zA-Z]*r[a-zA-Z]*') # -r, -fr + contains_r = bool([a for a in self._raw_args if r_re.match(a)]) + role_file_re = re.compile(r'--role-file($|=)') # --role-file foo, --role-file=foo + contains_role_file = bool([a for a in self._raw_args if role_file_re.match(a)]) + if self._implicit_role and (contains_r or contains_role_file): # Any collections in the requirements files will also be installed install_parser.add_argument('--keyring', dest='keyring', default=C.GALAXY_GPG_KEYRING, help='The keyring used during collection signature verification') @@ -1315,7 +1320,16 @@ class GalaxyCLI(CLI): ignore_errors = context.CLIARGS['ignore_errors'] no_deps = context.CLIARGS['no_deps'] force_with_deps = context.CLIARGS['force_with_deps'] - disable_gpg_verify = context.CLIARGS['disable_gpg_verify'] + try: + disable_gpg_verify = context.CLIARGS['disable_gpg_verify'] + except KeyError: + if self._implicit_role: + raise AnsibleError( + 'Unable to properly parse command line arguments. Please use "ansible-galaxy collection install" ' + 'instead of "ansible-galaxy install".' + ) + raise + # If `ansible-galaxy install` is used, collection-only options aren't available to the user and won't be in context.CLIARGS allow_pre_release = context.CLIARGS.get('allow_pre_release', False) upgrade = context.CLIARGS.get('upgrade', False) @@ -1657,7 +1671,7 @@ class GalaxyCLI(CLI): if response['count'] == 0: display.display("No roles match your search.", color=C.COLOR_ERROR) - return True + return 1 data = [u''] @@ -1680,7 +1694,7 @@ class GalaxyCLI(CLI): data = u'\n'.join(data) self.pager(data) - return True + return 0 def execute_import(self): """ used to import a role into Ansible Galaxy """ @@ -1786,7 +1800,7 @@ class GalaxyCLI(CLI): display.display(resp['status']) - return True + return 0 def main(args=None): |