Backportapalooza 7 15 (#78277)

* Pr 72292- Add context to inventory plugins (#78070)

* Add context to inventory plugins documentation

* Show how to add the inventory plugin to the `enable_plugins` configuration item - not just replace it.
* Show adding tags to `keyed_groups` without specifying the separator.
* Show adding more complex `groups` and `compose` statements, including using the ternary filter.
* As I added an additional group, I've updated the resulting `ansible-inventory` output accordingly.

(cherry picked from commit a77fc2e822)

* Update dpkg_selections.py (#78177)

* Update dpkg_selections.py to include an syntax example showing how to remove package holds

* Fix pep8 issue: dpkg_selections.py

Missed some trailing spaces when adding example text.

(cherry picked from commit 489b7f1859)

* fix ternary problem (#78186)

(cherry picked from commit 7ec8916097)

* documentation: become plugins: correct pluralization in description (#78196)

fixes #78195

(cherry picked from commit e10851d495)

* Update python_3_support.rst (#78239)

Fix invalid characters warning when using example group names. (Replace dashes in example group name with underscores.)

(cherry picked from commit be88250a83)

* Adding applicable licensing requirements (#78162)

(cherry picked from commit 6ddccc1604)

* Document choice to use Ansible Project in copyright lines (#78164)

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
(cherry picked from commit c9a341902b)

* stat only returns pw_name/gr_name if those can be looked up (#78183)

(cherry picked from commit 221af7640d)

* example showing how to deal with keys w/o apt_key (#78206)

(cherry picked from commit 0590ce065c)

* Migrate vmware.vmware_rest Dev Guide to collection (#78255)

(cherry picked from commit 048adac5b7)

* Updated release_and_maintenance.rst (#78272)

(cherry picked from commit 358a8ad7af)

Co-authored-by: Micah Beasley <MBfromOK@users.noreply.github.com>
Co-authored-by: Alex Willmer <alex@moreati.org.uk>
Co-authored-by: Nathan Hyde <nathanhyde@gmail.com>
Co-authored-by: Desmond Obisi <51109125+DesmondSanctity@users.noreply.github.com>
Co-authored-by: Evgeni Golov <evgeni@golov.de>
Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
Co-authored-by: Mario Lenz <m@riolenz.de>
Co-authored-by: Ompragash Viswanathan <21008429+Ompragash@users.noreply.github.com>
pull/78290/head
Sandra McCann 2 years ago committed by GitHub
parent 4b9434788b
commit 5d8bf08e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,28 +33,24 @@ Begin your Ansible module with ``#!/usr/bin/python`` - this "shebang" allows ``a
Copyright and license
=====================
After the shebang and UTF-8 coding, add a `copyright line <https://www.gnu.org/licenses/gpl-howto.en.html>`_ with the original copyright holder and a license declaration. The license declaration should be ONLY one line, not the full GPL prefix.:
After the shebang and UTF-8 coding, add a `copyright line <https://www.linuxfoundation.org/blog/copyright-notices-in-open-source-software-projects/>`_ with the original copyright holder and a license declaration. The license declaration should be ONLY one line, not the full GPL prefix.:
.. code-block:: python
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, Terry Jones <terry.jones@example.org>
# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
Major additions to the module (for instance, rewrites) may add additional copyright lines. Any legal review will include the source control history, so an exhaustive copyright header is not necessary.
Please do not edit the existing copyright year. This simplifies project administration and is unlikely to cause any interesting legal issues.
When adding a second copyright line for a significant feature or rewrite, add the newer line above the older one:
Additions to the module (for instance, rewrites) are not permitted to add additional copyright lines other than the default copyright statement if missing:
.. code-block:: python
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2017, [New Contributor(s)]
# Copyright: (c) 2015, [Original Contributor(s)]
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Copyright: Contributors to the Ansible project
Any legal review will include the source control history, so an exhaustive copyright header is not necessary.
Please do not include a copyright year. If the existing copyright statement includes a year, do not edit the existing copyright year. Any existing copyright header should not be modified without permission from the copyright author.
.. _ansible_metadata_block:

@ -4,108 +4,4 @@
Guidelines for VMware REST module development
*********************************************
The Ansible VMware REST collection (on `Galaxy <https://galaxy.ansible.com/vmware/vmware_rest>`_, source code `repository <https://github.com/ansible-collections/vmware.vmware_rest>`_) is maintained by Red Hat and the community.
.. contents::
:local:
Contribution process
====================
The modules of the vmware_rest collection are autogenerated by another tool called `vmware_rest_code_generator <https://github.com/ansible-collections/vmware_rest_code_generator>`.
If you would like to contribute a change, we would appreciate if you:
- submit a Github Pull Request (PR) against the vmware_rest_code_generator project
- but also ensure the generated modules are compliant with our quality criteria.
Requirements
============
You will need:
- Python 3.6 or greater
- the `tox <https://tox.readthedocs.io/en/latest/install.html>` command
vmware_rest_code_generator
==========================
Your contribution should follow the coding style of `Black <https://github.com/psf/black>`.
To run the code formatter, just run:
.. code-block:: shell
tox -e black
To regenerate the vmware_rest collection, you can use the following commands:
.. code-block:: shell
tox -e refresh_modules -- --target-dir ~/.ansible/collections/ansible_collections/vmware/vmware_rest
If you also want to update the EXAMPLE section of the modules, run:
.. code-block:: shell
tox -e refresh_examples -- --target-dir ~/.ansible/collections/ansible_collections/vmware/vmware_rest
Testing with ansible-test
=========================
All the modules are covered by a functional test. The tests are located in the :file:`tests/integration/targets/`.
To run the tests, you will need a vcenter instance and an ESXi.
black code formatter
^^^^^^^^^^^^^^^^^^^^
We follow the coding style of `Black <https://github.com/psf/black>`.
You can run the code formatter with the following command.
.. code-block:: shell
tox -e black
sanity tests
^^^^^^^^^^^^
Here we use Python 3.8, the minimal version is 3.6.
.. code-block:: shell
tox -e black
ansible-test sanity --debug --requirements --local --skip-test future-import-boilerplate --skip-test metaclass-boilerplate --python 3.8 -vvv
integration tests
^^^^^^^^^^^^^^^^^
These tests should be run against your test environment.
..warning:: The test suite will delete all the existing DC from your test environment.
First, prepare a configuration file, we call it :file:`/tmp/inventory-vmware_rest` in
this example:
.. code-block:: ini
[vmware_rest]
localhost ansible_connection=local ansible_python_interpreter=python
[vmware_rest:vars]
vcenter_hostname=vcenter.test
vcenter_username=administrator@vsphere.local
vcenter_password=kLRy|FXwZSHXW0w?Q:sO
esxi1_hostname=esxi1.test
esxi1_username=zuul
esxi1_password=f6QYNi65k05kv8m56
To run the tests, use the following command. You may want to adjust the Python version.
.. code-block:: shell
ansible-test network-integration --diff --no-temp-workdir --python 3.8 --inventory /tmp/inventory-vmware_rest zuul/
This guide has moved to :ref:`ansible_collections.vmware.vmware_rest.docsite.vmware_rest_devguide`.

@ -7,3 +7,6 @@
* All other ``module_utils`` must be licensed under BSD, so GPL-licensed third-party and Galaxy modules can use them.
* If there's doubt about the appropriate license for a file in ``module_utils``, the Ansible Core Team will decide during an Ansible Core Community Meeting.
* All other files shipped with Ansible, including all modules, must be licensed under the GPL license (GPLv3 or later).
* Existing license requirements still apply to content in ansible/ansible (ansible-core).
* Content that was previously in ansible/ansible or a collection and has moved to a new collection must retain the license it had in its prior repository.
* Copyright entries by previous committers must also be kept in any moved files.

@ -23,13 +23,20 @@ In some circumstances, for example, if the inventory plugin does not use a YAML
[inventory]
enable_plugins = host_list, script, auto, yaml, ini, toml
If the plugin is in a collection, use the fully qualified name:
If the plugin is in a collection and is not being picked up by the `auto` statement, you can append the fully qualified name:
.. code-block:: ini
[inventory]
enable_plugins = namespace.collection_name.inventory_plugin_name
enable_plugins = host_list, script, auto, yaml, ini, toml, namespace.collection_name.inventory_plugin_name
Or, if it is a local plugin, perhaps stored in the path set by :ref:`DEFAULT_INVENTORY_PLUGIN_PATH`, you could reference it as follows:
.. code-block:: ini
[inventory]
enable_plugins = host_list, script, auto, yaml, ini, toml, my_plugin
If you use a plugin that supports a YAML configuration source, make sure that the name matches the name provided in the ``plugin`` entry of the inventory source file.
.. _using_inventory:
@ -80,12 +87,24 @@ You can create dynamic groups using host variables with the constructed ``keyed_
- key: tags.Name
prefix: tag_Name_
separator: ""
# If you have a tag called "Role" which has the value "Webserver", this will add the group
# role_Webserver and add any hosts that have that tag assigned to it.
- key: tags.Role
prefix: role
groups:
# add hosts to the group development if any of the dictionary's keys or values is the word 'devel'
development: "'devel' in (tags|list)"
# add hosts to the "private_only" group if the host doesn't have a public IP associated to it
private_only: "public_ip_address is not defined"
compose:
# set the ansible_host variable to connect with the private IP address without changing the hostname
ansible_host: private_ip_address
# use a private address where a public one isn't assigned
ansible_host: public_ip_address|default(private_ip_address)
# alternatively, set the ansible_host variable to connect with the private IP address without changing the hostname
# ansible_host: private_ip_address
# if you *must* set a string here (perhaps to identify the inventory source if you have multiple
# accounts you want to use as sources), you need to wrap this in two sets of quotes, either ' then "
# or " then '
some_inventory_wide_string: '"Yes, you need both types of quotes here"'
Now the output of ``ansible-inventory -i demo.aws_ec2.yml --graph``:
@ -99,6 +118,8 @@ Now the output of ``ansible-inventory -i demo.aws_ec2.yml --graph``:
|--@development:
| |--ec2-12-345-678-901.compute-1.amazonaws.com
| |--ec2-98-765-432-10.compute-1.amazonaws.com
|--@role_Webserver
| |--ec2-12-345-678-901.compute-1.amazonaws.com
|--@tag_Name_ECS_Instance:
| |--ec2-98-765-432-10.compute-1.amazonaws.com
|--@tag_Name_Test_Server:

@ -52,11 +52,11 @@ Using Python 3 on the managed machines with commands and playbooks
localhost-py3 ansible_host=localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3
# Example of setting a group of hosts to use Python3
[py3-hosts]
[py3_hosts]
ubuntu16
fedora27
[py3-hosts:vars]
[py3_hosts:vars]
ansible_python_interpreter=/usr/bin/python3
.. seealso:: :ref:`intro_inventory` for more information.

@ -82,7 +82,7 @@ Ansible Community Package Release Status Core ver
================================== ============================ =========================
7.0.0 In development (unreleased) 2.14
`6.x Changelogs`_ Current 2.13
`5.x Changelogs`_ Unmaintained/EOL after 5.10 2.12
`5.x Changelogs`_ Unmaintained (end of life) 2.12
`4.x Changelogs`_ Unmaintained (end of life) 2.11
`3.x Changelogs`_ Unmaintained (end of life) 2.10
`2.10 Changelogs`_ Unmaintained (end of life) 2.10

@ -81,6 +81,18 @@ options:
'''
EXAMPLES = '''
- name: One way to avoid apt_key once it is removed from your distro
block:
- name: somerepo |no apt key
ansible.builtin.get_url:
url: https://download.example.com/linux/ubuntu/gpg
dest: /etc/apt/trusted.gpg.d/somerepo.asc
- name: somerepo | apt source
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/somerepo.asc] https://download.example.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
- name: Add an apt key by id from a keyserver
ansible.builtin.apt_key:
keyserver: keyserver.ubuntu.com

@ -131,6 +131,18 @@ EXAMPLES = '''
ansible.builtin.apt_repository:
repo: 'ppa:nginx/stable'
codename: trusty
- name: One way to avoid apt_key once it is removed from your distro
block:
- name: somerepo |no apt key
ansible.builtin.get_url:
url: https://download.example.com/linux/ubuntu/gpg
dest: /etc/apt/trusted.gpg.d/somerepo.asc
- name: somerepo | apt source
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/somerepo.asc] https://download.example.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
'''
RETURN = '''#'''

@ -46,6 +46,11 @@ EXAMPLES = '''
ansible.builtin.dpkg_selections:
name: python
selection: hold
- name: Allow python to be upgraded
ansible.builtin.dpkg_selections:
name: python
selection: install
'''
from ansible.module_utils.basic import AnsibleModule

@ -322,12 +322,12 @@ stat:
sample: 50ba294cdf28c0d5bcde25708df53346825a429f
pw_name:
description: User name of owner
returned: success, path exists and user can read stats and installed python supports it
returned: success, path exists, user can read stats, owner name can be looked up and installed python supports it
type: str
sample: httpd
gr_name:
description: Group name of owner
returned: success, path exists and user can read stats and installed python supports it
returned: success, path exists, user can read stats, owner group can be looked up and installed python supports it
type: str
sample: www-data
mimetype:

@ -8,7 +8,7 @@ DOCUMENTATION = """
name: runas
short_description: Run As user
description:
- This become plugins allows your remote/login user to execute commands as another user via the windows runas facility.
- This become plugin allows your remote/login user to execute commands as another user via the windows runas facility.
author: ansible (@core)
version_added: "2.8"
options:

@ -8,7 +8,7 @@ DOCUMENTATION = """
name: su
short_description: Substitute User
description:
- This become plugins allows your remote/login user to execute commands as another user via the su utility.
- This become plugin allows your remote/login user to execute commands as another user via the su utility.
author: ansible (@core)
version_added: "2.8"
options:

@ -8,7 +8,7 @@ DOCUMENTATION = """
name: sudo
short_description: Substitute User DO
description:
- This become plugins allows your remote/login user to execute commands as another user via the sudo utility.
- This become plugin allows your remote/login user to execute commands as another user via the sudo utility.
author: ansible (@core)
version_added: "2.8"
options:

Loading…
Cancel
Save