From aa67ff2cf26fe46d82cb56e4c4066fd652c9f03f Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 6 Jan 2022 17:33:14 -0800 Subject: [PATCH] Remove shebangs from core Python modules. (#76664) * Remove module shebangs. * Relax shebang check in validate-modules. * Add changelog fragment. --- changelogs/fragments/ansible-module-shebangs.yml | 3 +++ lib/ansible/modules/_include.py | 1 - lib/ansible/modules/apt.py | 1 - lib/ansible/modules/apt_key.py | 1 - lib/ansible/modules/apt_repository.py | 1 - lib/ansible/modules/assemble.py | 1 - lib/ansible/modules/assert.py | 1 - lib/ansible/modules/async_status.py | 1 - lib/ansible/modules/async_wrapper.py | 1 - lib/ansible/modules/blockinfile.py | 1 - lib/ansible/modules/command.py | 1 - lib/ansible/modules/copy.py | 1 - lib/ansible/modules/cron.py | 1 - lib/ansible/modules/debconf.py | 1 - lib/ansible/modules/debug.py | 1 - lib/ansible/modules/dnf.py | 1 - lib/ansible/modules/dpkg_selections.py | 1 - lib/ansible/modules/expect.py | 1 - lib/ansible/modules/fail.py | 1 - lib/ansible/modules/fetch.py | 1 - lib/ansible/modules/file.py | 1 - lib/ansible/modules/find.py | 1 - lib/ansible/modules/gather_facts.py | 1 - lib/ansible/modules/get_url.py | 1 - lib/ansible/modules/getent.py | 1 - lib/ansible/modules/git.py | 1 - lib/ansible/modules/group.py | 1 - lib/ansible/modules/hostname.py | 1 - lib/ansible/modules/import_playbook.py | 1 - lib/ansible/modules/import_role.py | 1 - lib/ansible/modules/import_tasks.py | 1 - lib/ansible/modules/include_role.py | 1 - lib/ansible/modules/include_tasks.py | 1 - lib/ansible/modules/include_vars.py | 1 - lib/ansible/modules/iptables.py | 1 - lib/ansible/modules/known_hosts.py | 1 - lib/ansible/modules/lineinfile.py | 1 - lib/ansible/modules/meta.py | 1 - lib/ansible/modules/package.py | 1 - lib/ansible/modules/package_facts.py | 1 - lib/ansible/modules/pause.py | 1 - lib/ansible/modules/ping.py | 1 - lib/ansible/modules/pip.py | 1 - lib/ansible/modules/reboot.py | 1 - lib/ansible/modules/replace.py | 1 - lib/ansible/modules/rpm_key.py | 1 - lib/ansible/modules/service.py | 1 - lib/ansible/modules/service_facts.py | 1 - lib/ansible/modules/set_fact.py | 1 - lib/ansible/modules/set_stats.py | 1 - lib/ansible/modules/setup.py | 1 - lib/ansible/modules/shell.py | 1 - lib/ansible/modules/slurp.py | 1 - lib/ansible/modules/stat.py | 1 - lib/ansible/modules/subversion.py | 1 - lib/ansible/modules/systemd.py | 1 - lib/ansible/modules/sysvinit.py | 1 - lib/ansible/modules/tempfile.py | 1 - lib/ansible/modules/template.py | 1 - lib/ansible/modules/unarchive.py | 1 - lib/ansible/modules/uri.py | 1 - lib/ansible/modules/user.py | 1 - lib/ansible/modules/validate_argument_spec.py | 1 - lib/ansible/modules/wait_for.py | 1 - lib/ansible/modules/wait_for_connection.py | 1 - lib/ansible/modules/yum.py | 1 - lib/ansible/modules/yum_repository.py | 1 - .../sanity/validate-modules/validate_modules/main.py | 11 ++++++++++- 68 files changed, 13 insertions(+), 67 deletions(-) create mode 100644 changelogs/fragments/ansible-module-shebangs.yml diff --git a/changelogs/fragments/ansible-module-shebangs.yml b/changelogs/fragments/ansible-module-shebangs.yml new file mode 100644 index 00000000000..4b41ec605b6 --- /dev/null +++ b/changelogs/fragments/ansible-module-shebangs.yml @@ -0,0 +1,3 @@ +minor_changes: + - ansible-core modules - Remove unused Python shebangs from built-in modules. + - ansible-test - Accept new-style Python modules without a shebang. diff --git a/lib/ansible/modules/_include.py b/lib/ansible/modules/_include.py index d9f45aa15ce..9daabc37580 100644 --- a/lib/ansible/modules/_include.py +++ b/lib/ansible/modules/_include.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: Ansible Project diff --git a/lib/ansible/modules/apt.py b/lib/ansible/modules/apt.py index 67ab4096310..7e4ac75ff0d 100644 --- a/lib/ansible/modules/apt.py +++ b/lib/ansible/modules/apt.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Flowroute LLC diff --git a/lib/ansible/modules/apt_key.py b/lib/ansible/modules/apt_key.py index ea7b8bd2802..b550d76c1eb 100644 --- a/lib/ansible/modules/apt_key.py +++ b/lib/ansible/modules/apt_key.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/apt_repository.py b/lib/ansible/modules/apt_repository.py index 2eb6dd97de4..0730eefb388 100644 --- a/lib/ansible/modules/apt_repository.py +++ b/lib/ansible/modules/apt_repository.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # encoding: utf-8 # Copyright: (c) 2012, Matt Wright diff --git a/lib/ansible/modules/assemble.py b/lib/ansible/modules/assemble.py index 271e05adde8..8fad49c3b94 100644 --- a/lib/ansible/modules/assemble.py +++ b/lib/ansible/modules/assemble.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Stephen Fromm diff --git a/lib/ansible/modules/assert.py b/lib/ansible/modules/assert.py index 08b72606720..100dda2213d 100644 --- a/lib/ansible/modules/assert.py +++ b/lib/ansible/modules/assert.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Dag Wieers diff --git a/lib/ansible/modules/async_status.py b/lib/ansible/modules/async_status.py index 4ab0ea82684..30ce976f201 100644 --- a/lib/ansible/modules/async_status.py +++ b/lib/ansible/modules/async_status.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan , and others diff --git a/lib/ansible/modules/async_wrapper.py b/lib/ansible/modules/async_wrapper.py index e11fb6ae1e4..dd6bb5b73fc 100644 --- a/lib/ansible/modules/async_wrapper.py +++ b/lib/ansible/modules/async_wrapper.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan , and others diff --git a/lib/ansible/modules/blockinfile.py b/lib/ansible/modules/blockinfile.py index fbefb4643cf..674c6695120 100644 --- a/lib/ansible/modules/blockinfile.py +++ b/lib/ansible/modules/blockinfile.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2014, 2015 YAEGASHI Takeshi diff --git a/lib/ansible/modules/command.py b/lib/ansible/modules/command.py index 1e0ff2f615d..47672853740 100644 --- a/lib/ansible/modules/command.py +++ b/lib/ansible/modules/command.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan , and others diff --git a/lib/ansible/modules/copy.py b/lib/ansible/modules/copy.py index 2febd91a628..cb518d82272 100644 --- a/lib/ansible/modules/copy.py +++ b/lib/ansible/modules/copy.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/cron.py b/lib/ansible/modules/cron.py index ba00916857d..9b4c96ca429 100644 --- a/lib/ansible/modules/cron.py +++ b/lib/ansible/modules/cron.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Dane Summers diff --git a/lib/ansible/modules/debconf.py b/lib/ansible/modules/debconf.py index 375e4f8497b..d30afd7ab8b 100644 --- a/lib/ansible/modules/debconf.py +++ b/lib/ansible/modules/debconf.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2014, Brian Coca diff --git a/lib/ansible/modules/debug.py b/lib/ansible/modules/debug.py index 7bfcef0d23c..a4707a58bc2 100644 --- a/lib/ansible/modules/debug.py +++ b/lib/ansible/modules/debug.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012 Dag Wieers diff --git a/lib/ansible/modules/dnf.py b/lib/ansible/modules/dnf.py index 423b1e91704..005e9081e7a 100644 --- a/lib/ansible/modules/dnf.py +++ b/lib/ansible/modules/dnf.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2015 Cristian van Ee diff --git a/lib/ansible/modules/dpkg_selections.py b/lib/ansible/modules/dpkg_selections.py index 563868f33ac..f8991e5730f 100644 --- a/lib/ansible/modules/dpkg_selections.py +++ b/lib/ansible/modules/dpkg_selections.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright: Ansible Project diff --git a/lib/ansible/modules/expect.py b/lib/ansible/modules/expect.py index bc7633072c3..99ffe9f263a 100644 --- a/lib/ansible/modules/expect.py +++ b/lib/ansible/modules/expect.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2015, Matt Martz diff --git a/lib/ansible/modules/fail.py b/lib/ansible/modules/fail.py index 172f1afb504..882ced041ae 100644 --- a/lib/ansible/modules/fail.py +++ b/lib/ansible/modules/fail.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Dag Wieers diff --git a/lib/ansible/modules/fetch.py b/lib/ansible/modules/fetch.py index d507cedf757..5ea1038a7a5 100644 --- a/lib/ansible/modules/fetch.py +++ b/lib/ansible/modules/fetch.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2017, Ansible Project diff --git a/lib/ansible/modules/file.py b/lib/ansible/modules/file.py index 34f9249087d..65b4e6c1eea 100644 --- a/lib/ansible/modules/file.py +++ b/lib/ansible/modules/file.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/find.py b/lib/ansible/modules/find.py index e7d8357c197..188c3dc5b0c 100644 --- a/lib/ansible/modules/find.py +++ b/lib/ansible/modules/find.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2014, Ruggero Marchei diff --git a/lib/ansible/modules/gather_facts.py b/lib/ansible/modules/gather_facts.py index 4e5c85bc7de..2febf8e4738 100644 --- a/lib/ansible/modules/gather_facts.py +++ b/lib/ansible/modules/gather_facts.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/get_url.py b/lib/ansible/modules/get_url.py index 405f8d0514c..8ad8cccca85 100644 --- a/lib/ansible/modules/get_url.py +++ b/lib/ansible/modules/get_url.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Jan-Piet Mens diff --git a/lib/ansible/modules/getent.py b/lib/ansible/modules/getent.py index 9691d74399d..29118c2bd2a 100644 --- a/lib/ansible/modules/getent.py +++ b/lib/ansible/modules/getent.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2014, Brian Coca diff --git a/lib/ansible/modules/git.py b/lib/ansible/modules/git.py index ed87088e2b9..85c8869ae90 100644 --- a/lib/ansible/modules/git.py +++ b/lib/ansible/modules/git.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/group.py b/lib/ansible/modules/group.py index 2a18bec4032..7e40531b6e9 100644 --- a/lib/ansible/modules/group.py +++ b/lib/ansible/modules/group.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Stephen Fromm diff --git a/lib/ansible/modules/hostname.py b/lib/ansible/modules/hostname.py index 3efee724b8d..4ded676e385 100644 --- a/lib/ansible/modules/hostname.py +++ b/lib/ansible/modules/hostname.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2013, Hiroaki Nakamura diff --git a/lib/ansible/modules/import_playbook.py b/lib/ansible/modules/import_playbook.py index 74ccdd21f1a..c9c2bfde54c 100644 --- a/lib/ansible/modules/import_playbook.py +++ b/lib/ansible/modules/import_playbook.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: Ansible Project diff --git a/lib/ansible/modules/import_role.py b/lib/ansible/modules/import_role.py index c75993eea65..dc8e63e2ed4 100644 --- a/lib/ansible/modules/import_role.py +++ b/lib/ansible/modules/import_role.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/import_tasks.py b/lib/ansible/modules/import_tasks.py index b7a67f0d9b5..a4ffe617709 100644 --- a/lib/ansible/modules/import_tasks.py +++ b/lib/ansible/modules/import_tasks.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: Ansible Project diff --git a/lib/ansible/modules/include_role.py b/lib/ansible/modules/include_role.py index 88983ce1564..362f4eb3322 100644 --- a/lib/ansible/modules/include_role.py +++ b/lib/ansible/modules/include_role.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: Ansible Project diff --git a/lib/ansible/modules/include_tasks.py b/lib/ansible/modules/include_tasks.py index f004673aeea..413898358c4 100644 --- a/lib/ansible/modules/include_tasks.py +++ b/lib/ansible/modules/include_tasks.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: Ansible Project diff --git a/lib/ansible/modules/include_vars.py b/lib/ansible/modules/include_vars.py index 131321978fa..5a524cb0666 100644 --- a/lib/ansible/modules/include_vars.py +++ b/lib/ansible/modules/include_vars.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/iptables.py b/lib/ansible/modules/iptables.py index 0530fdd6120..ec44da864fb 100644 --- a/lib/ansible/modules/iptables.py +++ b/lib/ansible/modules/iptables.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2015, Linus Unnebäck diff --git a/lib/ansible/modules/known_hosts.py b/lib/ansible/modules/known_hosts.py index df8a1dc11f4..95ae95a824c 100644 --- a/lib/ansible/modules/known_hosts.py +++ b/lib/ansible/modules/known_hosts.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright: (c) 2014, Matthew Vernon # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/lineinfile.py b/lib/ansible/modules/lineinfile.py index 0ba1431364c..5db6a93f217 100644 --- a/lib/ansible/modules/lineinfile.py +++ b/lib/ansible/modules/lineinfile.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Daniel Hokka Zakrisson diff --git a/lib/ansible/modules/meta.py b/lib/ansible/modules/meta.py index 84962ca0bf3..f3e69b54444 100644 --- a/lib/ansible/modules/meta.py +++ b/lib/ansible/modules/meta.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2016, Ansible, a Red Hat company diff --git a/lib/ansible/modules/package.py b/lib/ansible/modules/package.py index e9c177ff9cd..6078739f2ff 100644 --- a/lib/ansible/modules/package.py +++ b/lib/ansible/modules/package.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2015, Ansible Project diff --git a/lib/ansible/modules/package_facts.py b/lib/ansible/modules/package_facts.py index 30a2e0c0957..41af47039b4 100644 --- a/lib/ansible/modules/package_facts.py +++ b/lib/ansible/modules/package_facts.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/pause.py b/lib/ansible/modules/pause.py index c8725fe0dce..440359c7a27 100644 --- a/lib/ansible/modules/pause.py +++ b/lib/ansible/modules/pause.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/ping.py b/lib/ansible/modules/ping.py index 17b1cea2907..6aa7f0e8147 100644 --- a/lib/ansible/modules/ping.py +++ b/lib/ansible/modules/ping.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/pip.py b/lib/ansible/modules/pip.py index f2d9cc1e646..82ba71311cb 100644 --- a/lib/ansible/modules/pip.py +++ b/lib/ansible/modules/pip.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Matt Wright diff --git a/lib/ansible/modules/reboot.py b/lib/ansible/modules/reboot.py index ff7b8dbd970..f842454f4a5 100644 --- a/lib/ansible/modules/reboot.py +++ b/lib/ansible/modules/reboot.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2018, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/replace.py b/lib/ansible/modules/replace.py index ca8d57c58bb..164fac35a2e 100644 --- a/lib/ansible/modules/replace.py +++ b/lib/ansible/modules/replace.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2013, Evan Kaufman diff --git a/lib/ansible/modules/service_facts.py b/lib/ansible/modules/service_facts.py index 1e01093918e..cad1662a018 100644 --- a/lib/ansible/modules/service_facts.py +++ b/lib/ansible/modules/service_facts.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # originally copied from AWX's scan_services module to bring this functionality diff --git a/lib/ansible/modules/set_fact.py b/lib/ansible/modules/set_fact.py index f4a0317a263..de761143494 100644 --- a/lib/ansible/modules/set_fact.py +++ b/lib/ansible/modules/set_fact.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2013, Dag Wieers (@dagwieers) diff --git a/lib/ansible/modules/set_stats.py b/lib/ansible/modules/set_stats.py index 4c65125a2bf..3fa0975cddc 100644 --- a/lib/ansible/modules/set_stats.py +++ b/lib/ansible/modules/set_stats.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2016, Ansible RedHat, Inc diff --git a/lib/ansible/modules/setup.py b/lib/ansible/modules/setup.py index a8816a2211c..715ba13d9dc 100644 --- a/lib/ansible/modules/setup.py +++ b/lib/ansible/modules/setup.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/shell.py b/lib/ansible/modules/shell.py index b321cee96ed..6a6f9543f9c 100644 --- a/lib/ansible/modules/shell.py +++ b/lib/ansible/modules/shell.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2018, Ansible Project diff --git a/lib/ansible/modules/slurp.py b/lib/ansible/modules/slurp.py index 404cdc07f61..9040563a95c 100644 --- a/lib/ansible/modules/slurp.py +++ b/lib/ansible/modules/slurp.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/stat.py b/lib/ansible/modules/stat.py index 262ee94ae73..8c8d5d31b70 100644 --- a/lib/ansible/modules/stat.py +++ b/lib/ansible/modules/stat.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) diff --git a/lib/ansible/modules/subversion.py b/lib/ansible/modules/subversion.py index afd178c2fc8..a63de3c5b3f 100644 --- a/lib/ansible/modules/subversion.py +++ b/lib/ansible/modules/subversion.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/systemd.py b/lib/ansible/modules/systemd.py index 4f5827cd281..6fc606253eb 100644 --- a/lib/ansible/modules/systemd.py +++ b/lib/ansible/modules/systemd.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2016, Brian Coca diff --git a/lib/ansible/modules/sysvinit.py b/lib/ansible/modules/sysvinit.py index 333be6a0193..0fa23ee8bfa 100644 --- a/lib/ansible/modules/sysvinit.py +++ b/lib/ansible/modules/sysvinit.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2017, Brian Coca # (c) 2017, Adam Miller diff --git a/lib/ansible/modules/tempfile.py b/lib/ansible/modules/tempfile.py index 62b846210dc..10594dec0dc 100644 --- a/lib/ansible/modules/tempfile.py +++ b/lib/ansible/modules/tempfile.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2016, Krzysztof Magosa diff --git a/lib/ansible/modules/template.py b/lib/ansible/modules/template.py index a584a47bb24..4924bca1f17 100644 --- a/lib/ansible/modules/template.py +++ b/lib/ansible/modules/template.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2017, Ansible Project diff --git a/lib/ansible/modules/unarchive.py b/lib/ansible/modules/unarchive.py index 738df631623..7d00f2425a8 100644 --- a/lib/ansible/modules/unarchive.py +++ b/lib/ansible/modules/unarchive.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Michael DeHaan diff --git a/lib/ansible/modules/uri.py b/lib/ansible/modules/uri.py index 88034c03a13..dd42f7eb601 100644 --- a/lib/ansible/modules/uri.py +++ b/lib/ansible/modules/uri.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2013, Romeo Theriault diff --git a/lib/ansible/modules/user.py b/lib/ansible/modules/user.py index 9f478b25ad4..6a49207f04c 100644 --- a/lib/ansible/modules/user.py +++ b/lib/ansible/modules/user.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Stephen Fromm diff --git a/lib/ansible/modules/validate_argument_spec.py b/lib/ansible/modules/validate_argument_spec.py index 291890e3ae3..e7b5f1ea075 100644 --- a/lib/ansible/modules/validate_argument_spec.py +++ b/lib/ansible/modules/validate_argument_spec.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2021 Red Hat diff --git a/lib/ansible/modules/wait_for.py b/lib/ansible/modules/wait_for.py index c55229db4b5..d382f05defb 100644 --- a/lib/ansible/modules/wait_for.py +++ b/lib/ansible/modules/wait_for.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Jeroen Hoekx diff --git a/lib/ansible/modules/wait_for_connection.py b/lib/ansible/modules/wait_for_connection.py index a8a27c5e7da..43be21fc717 100644 --- a/lib/ansible/modules/wait_for_connection.py +++ b/lib/ansible/modules/wait_for_connection.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2017, Dag Wieers (@dagwieers) diff --git a/lib/ansible/modules/yum.py b/lib/ansible/modules/yum.py index c9c3f234ec3..ba8fd24b588 100644 --- a/lib/ansible/modules/yum.py +++ b/lib/ansible/modules/yum.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Red Hat, Inc diff --git a/lib/ansible/modules/yum_repository.py b/lib/ansible/modules/yum_repository.py index 698bd7580c0..bde2b6bab82 100644 --- a/lib/ansible/modules/yum_repository.py +++ b/lib/ansible/modules/yum_repository.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # encoding: utf-8 # (c) 2015-2016, Jiri Tyr diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py index 5ab8f529267..0f88ecadd2a 100644 --- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py +++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py @@ -39,13 +39,14 @@ from fnmatch import fnmatch import yaml from ansible import __version__ as ansible_version -from ansible.executor.module_common import REPLACER_WINDOWS +from ansible.executor.module_common import REPLACER_WINDOWS, NEW_STYLE_PYTHON_MODULE_RE from ansible.module_utils.common._collections_compat import Mapping from ansible.module_utils.common.parameters import DEFAULT_TYPE_VALIDATORS from ansible.plugins.loader import fragment_loader from ansible.utils.collection_loader._collection_finder import _AnsibleCollectionFinder from ansible.utils.plugin_docs import REJECTLIST, add_collection_to_versions_and_dates, add_fragments, get_docstring from ansible.utils.version import SemanticVersion +from ansible.module_utils.basic import to_bytes from .module_args import AnsibleModuleImportError, AnsibleModuleNotInitialized, get_argument_spec @@ -433,7 +434,15 @@ class ModuleValidator(Validator): ) return + missing_python_interpreter = False + if not self.text.startswith('#!/usr/bin/python'): + if NEW_STYLE_PYTHON_MODULE_RE.search(to_bytes(self.text)): + missing_python_interpreter = self.text.startswith('#!') # shebang optional, but if present must match + else: + missing_python_interpreter = True # shebang required + + if missing_python_interpreter: self.reporter.error( path=self.object_path, code='missing-python-interpreter',