Skip to content

Instantly share code, notes, and snippets.

@s-hertel
s-hertel / inventory
Created October 4, 2022 13:08
test case for 78805
[pause_group0]
pause0
pause1
pause2
[pause_group1]
pause3
pause4
pause5
@s-hertel
s-hertel / gist:9347e9321ae53149b0345d94d3093566
Created September 20, 2022 15:55
modules in group/azure
azure_rm_acs
azure_rm_aks
azure_rm_aks_facts
azure_rm_appserviceplan
azure_rm_appserviceplan_facts
azure_rm_availabilityset
azure_rm_availabilityset_facts
azure_rm_containerinstance
azure_rm_containerregistry
azure_rm_deployment
@s-hertel
s-hertel / ansible-galaxy_signature_verification.rst
Last active March 7, 2022 18:47
State table for ansible-galaxy signature verification

+---------------------+----------------------------------+--------------------------------------------------------------+ | | Unconfigured keyring (default) | Configured keyring | +=====================+==================================+================================+=============================+ | | | R == -1 ("all") | R >= 1 (default) | | | +-----------------+--------------+--------------+--------------+ | | | F == 0 | F > 0 | S >= R | S < R | +---------------------+----------------------------------+-----------------+--------------+--------------+--------------+ | U >= 1 | Invalid option error 1 | Success 2| Fail | Success | Fail | +---------------------+-------------------------

@s-hertel
s-hertel / gist.rst
Created May 5, 2021 15:12
2.9 - 2.12 action_groups overview

In Ansible <= 2.9 the module_defaults keyword supports a hardcoded list of groups to define common arguments for actions. The actions in each group are also hardcoded in core. For example, the group aws contains the modules ec2 and aws_s3, and can be used like this:

module_defaults:
  group/aws:
    aws_access_key_id: "{{ access_key }}"
    aws_secret_access_key: "{{ secret_key }}"
tasks:
  - aws_s3: ...
@s-hertel
s-hertel / reboot.diff
Created April 19, 2021 22:04
example of generic retry wrapper in reboot module
diff --git a/lib/ansible/plugins/action/reboot.py b/lib/ansible/plugins/action/reboot.py
index 64397b12fa..12ecdaee0b 100644
--- a/lib/ansible/plugins/action/reboot.py
+++ b/lib/ansible/plugins/action/reboot.py
@@ -12,6 +12,7 @@ from datetime import datetime, timedelta
from ansible.errors import AnsibleError, AnsibleConnectionFailure
from ansible.module_utils._text import to_native, to_text
+from ansible.module_utils.api import retry_with_delays_and_condition
from ansible.module_utils.common.validation import check_type_list, check_type_str
@s-hertel
s-hertel / gist.yml
Created April 1, 2021 14:31
module_defaults with yaml anchor
module_defaults:
group/aws: &aws_connection_info
...
# module_defaults does not work in conjunction with the 'collections' keyword
# use the fully qualified plugin name to ensure this works however the module is called
# and continues to work in the future
community.aws.new_module:
<<: *aws_connection_info
# test_aws_ec2.yml:
# plugin: amazon.aws.aws_ec2
# regions: us-east-1
export AWS_PROFILE=shertel
ansible-inventory -i test_aws_ec2.yml --list
@s-hertel
s-hertel / inventory_source_1.yml
Created October 21, 2020 20:17
test composing variables
# add hosts and hostvars to inventory with the yaml inventory plugin
all:
hosts:
host1:
a: 'is_defined'
host2:
diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py
index 79aa3eb1ec..079e488128 100644
--- a/lib/ansible/cli/doc.py
+++ b/lib/ansible/cli/doc.py
@@ -161,6 +161,7 @@ class DocCLI(CLI):
# add to plugin paths from command line
basedir = context.CLIARGS['basedir']
if basedir:
+ basedir = os.path.abspath(basedir)
AnsibleCollectionConfig.playbook_paths = basedir
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index bda38b0bdf..e3da2fd038 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -1032,6 +1032,8 @@ class TaskExecutor:
# let action plugin override module, fallback to 'normal' action plugin otherwise
if self._shared_loader_obj.action_loader.has_plugin(self._task.action, collection_list=collections):
handler_name = self._task.action
+ elif self._shared_loader_obj.action_loader.has_plugin(self._task.abbreviated_name, collection_list=collections):
+ handler_name = self._task.abbreviated_name