From d07bc25fc2446b2291bcc50bb3e5d4485630e000 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 6 Sep 2018 03:18:27 +0700 Subject: [PATCH] Remove restriction on add_host There's actually not anything unsafe about add_host. Doing CD from Zuul requires being able to add hosts, so relax the restriction. Change-Id: I7a5992808773722f3b81890fb4193da202cfea68 --- .../relax-add-host-6eeccd37bfa414ce.yaml | 4 +++ zuul/ansible/action/add_host.py | 26 ------------------- zuul/ansible/paths.py | 4 --- 3 files changed, 4 insertions(+), 30 deletions(-) create mode 100644 releasenotes/notes/relax-add-host-6eeccd37bfa414ce.yaml delete mode 100644 zuul/ansible/action/add_host.py diff --git a/releasenotes/notes/relax-add-host-6eeccd37bfa414ce.yaml b/releasenotes/notes/relax-add-host-6eeccd37bfa414ce.yaml new file mode 100644 index 0000000000..3e66e8baf8 --- /dev/null +++ b/releasenotes/notes/relax-add-host-6eeccd37bfa414ce.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + The restriction on using ``add_host`` in playbooks has been lifted. diff --git a/zuul/ansible/action/add_host.py b/zuul/ansible/action/add_host.py deleted file mode 100644 index d4b24aa555..0000000000 --- a/zuul/ansible/action/add_host.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2016 Red Hat, Inc. -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see . - -from zuul.ansible import paths -add_host = paths._import_ansible_action_plugin("add_host") - - -class ActionModule(add_host.ActionModule): - - def run(self, tmp=None, task_vars=None): - - return dict( - failed=True, - msg="Adding hosts to the inventory is prohibited") diff --git a/zuul/ansible/paths.py b/zuul/ansible/paths.py index dc624b945b..da031ea49c 100644 --- a/zuul/ansible/paths.py +++ b/zuul/ansible/paths.py @@ -176,10 +176,6 @@ def _is_localhost_task(task): # # localhost is special, since it's not in the inventory but instead is # added directly by ansible. - # - # The only way a user could supply a remote_addr with arbitrary ipv6 - # values is if they used add_host - which we don't let unprivileged code - # do. if (task._play_context.connection == 'local' or task._play_context.remote_addr == 'localhost'