Skip to content

Instantly share code, notes, and snippets.

@gundalow
Last active August 18, 2020 17:18
Show Gist options
  • Save gundalow/f37bda8e9a3eb54476b7cdc1aeced119 to your computer and use it in GitHub Desktop.
Save gundalow/f37bda8e9a3eb54476b7cdc1aeced119 to your computer and use it in GitHub Desktop.
validate
---
- name: Checkout all collections
connection: local
gather_facts: no
hosts: all
vars:
basedir: "/tmp/routing_validation/ansible_collections/"
galaxydir: "/tmp/routing_validation_tmp/ansible_collections/"
tasks:
- name: Create base directory
file:
name: "{{ item }}"
state: directory
loop:
- basedir
- galaxydir
# We checkout via Git (rather than collection) as that should give us better indication of endstate (ie soon to be)
- name: Checkout collection
git:
repo: "ssh://git@github.com/{{ item.repo }}.git"
dest: "{{ basedir }}/{{ item.namespace }}/{{ item.collection }}"
#version: "master"
recursive: no
accept_hostkey: yes
ignore_errors: yes # So local modifications don't error
loop:
## amazon
- { namespace: amazon, collection: aws, repo: ansible-collections/amazon.aws }
## community
- { namespace: community, collection: aws, repo: ansible-collections/community.aws }
- { namespace: community, collection: azure, repo: ansible-collections/community.azure }
- { namespace: community, collection: crypto, repo: ansible-collections/community.crypto }
- { namespace: community, collection: digitalocean, repo: ansible-collections/community.crypto }
- { namespace: community, collection: general, repo: ansible-collections/community.general }
- { namespace: community, collection: grafana, repo: ansible-collections/community.grafana }
- { namespace: community, collection: kubernetes, repo: ansible-collections/community.kubernetes }
- { namespace: community, collection: libvirt, repo: ansible-collections/community.libvirt }
- { namespace: community, collection: mongodb, repo: ansible-collections/community.mongodb }
- { namespace: community, collection: mysql, repo: ansible-collections/community.mongodb }
- { namespace: community, collection: network, repo: ansible-collections/community.network }
- { namespace: community, collection: proxysql, repo: ansible-collections/community.proxysql }
- { namespace: community, collection: rabbitmq, repo: ansible-collections/community.rabbitmq }
- { namespace: community, collection: skydive, repo: ansible-collections/community.skydive }
- { namespace: community, collection: vmware, repo: ansible-collections/vmware }
- { namespace: community, collection: windows, repo: ansible-collections/community.windows }
- { namespace: community, collection: zabbix, repo: ansible-collections/community.zabbix }
## ansible
- { namespace: ansible, collection: netcommon, repo: ansible-collections/ansible.netcommon }
- { namespace: ansible, collection: posix, repo: ansible-collections/ansible.posix }
- { namespace: ansible, collection: windows, repo: ansible-collections/ansible.windows }
## other gh/ansible-collections
- { namespace: arista, collection: eos, repo: ansible-collections/arista.eos }
- { namespace: azure, collection: azcollection, repo: ansible-collections/azure }
- { namespace: cisco, collection: asa, repo: ansible-collections/cisco.asa }
- { namespace: cisco, collection: ios, repo: ansible-collections/cisco.ios }
- { namespace: cisco, collection: iosxr, repo: ansible-collections/cisco.iosxr }
- { namespace: cisco, collection: nxos, repo: ansible-collections/cisco.nxos }
- { namespace: dellemc, collection: os10, repo: ansible-collections/dellemc.os10 }
- { namespace: dellemc, collection: os6, repo: ansible-collections/dellemc.os6 }
- { namespace: dellemc, collection: os9, repo: ansible-collections/dellemc.os9 }
- { namespace: frr, collection: frr, repo: ansible-collections/frr.frr }
- { namespace: google, collection: cloud, repo: ansible-collections/google.cloud }
- { namespace: hetzner, collection: hcloud, repo: ansible-collections/hetzner.hcloud }
- { namespace: ibm, collection: qradar, repo: ansible-collections/ibm.qradar }
- { namespace: junipernetworks, collection: junos, repo: ansible-collections/junipernetworks.junos }
- { namespace: mellanox, collection: onyx, repo: ansible-collections/mellanox.onyx }
- { namespace: openvswitch, collection: openvswitch, repo: ansible-collections/openvswitch.openvswitch }
- { namespace: vyos, collection: vyos, repo: ansible-collections/vyos }
## Other GitHub Orgs
- { namespace: check_point, collection: mgmt, repo: CheckPointSW/CheckPointAnsibleMgmtCollection }
- { namespace: cisco, collection: aci, repo: CiscoDevNet/ansible-aci }
- { namespace: cisco, collection: intersight, repo: CiscoDevNet/ansible-intersight }
- { namespace: cisco, collection: meraki, repo: CiscoDevNet/ansible-meraki }
- { namespace: cisco, collection: mso, repo: CiscoDevNet/ansible-mso }
- { namespace: cisco, collection: ucs, repo: CiscoDevNet/ansible-ucs }
- { namespace: cloudscale_ch, collection: cloud, repo: cloudscale-ch/ansible-collection-cloudscale }
- { namespace: containers, collection: podman, repo: containers/ansible-podman-collections }
- { namespace: cyberark, collection: conjur, repo: cyberark/ansible-conjur-collection }
- { namespace: cyberark, collection: pas, repo: cyberark/ansible-security-automation-collection }
- { namespace: fortinet, collection: fortimanager, repo: fortinet-ansible-dev/ansible-galaxy-fortimanager-collection }
- { namespace: fortinet, collection: fortios, repo: fortinet-ansible-dev/ansible-galaxy-fortios-collection }
- { namespace: infobox, collection: nios_modules, repo: infobloxopen/infoblox-ansible }
- { namespace: netapp_eseries, collection: santricity, repo: netappeseries/santricity }
- { namespace: netbox, collection: netbox, repo: netbox-community/ansible_modules }
- { namespace: ngine_io, collection: cloudstack, repo: ngine-io/ansible-collection-cloudstack }
- { namespace: ngine_io, collection: vultr, repo: ngine-io/ansible-collection-vultr }
- { namespace: ovirt, collection: ovirt, repo: ovirt/ovirt-ansible-collection }
- { namespace: servicenow, collection: servicenow, repo: ServiceNowITOM/servicenow-ansible }
- { namespace: splunk, collection: es, repo: ansible-collections/splunk.es }
- { namespace: theforeman, collection: foreman, repo: theforeman/foreman-ansible-modules }
- name: Install other collections
shell: ansible-galaxy collection install -i --no-deps -p {{ galaxydir }} {{ item }}
#ignore_errors: yes # So local modifications don't error
loop:
- awx.awx # Collection in subdirectory of repo
- chocolatey.chocolatey # subdirectory
- f5networks.f5_modules # repo structure
- netapp.aws # One repo with multiple collections
- netapp.elementsw # One repo with multiple collections
- netapp.ontap # One repo with multiple collections
- openstack.cloud # Not on GitHub
- purestorage.flasharray # repo structure
- purestorage.flashblade # repo structure
- wti.remote # directory structure
# Add to test/lib/ansible_test/_data/sanity/code-smell/runtime-meta.py
# This maybe moved to https://github.com/ansible-community/ansibulled
for plugin_type in sorted(list(plugin_schema.schema.keys())):
for plugin, file_meta in routing['plugin_routing'][plugin_type].items():
try:
namespace, collection, new_name = routing['plugin_routing'][plugin_type][plugin]['redirect'].split('.')
except ValueError:
if "ansible_collections.testns" not in file_meta:
print("%s:%d:%d: Can't failure to process line '%s', '%s'" %
(path, 0, 0, plugin, file_meta))
continue
if namespace == 'testns':
# This is a test entry, so ignore
continue
if namespace == "ansible" and collection == "builtin":
continue
expected_path = "/tmp/routing_validation/ansible_collections/%s/%s/plugins/%s" % ( namespace, collection, plugin_type)
found_plugin = False
if os.path.exists('%s/%s.py' % (expected_path, new_name)):
found_plugin = True
elif True: #namespace == 'community' and collection in ['general', 'network']:
if plugin_type in ['modules','module_utils']:
if glob.glob('%s/**/%s.py' % (expected_path, new_name), recursive = True):
found_plugin = True
if not found_plugin and namespace == "ansible" and collection == "windows":
if os.path.exists('%s/%s.ps1' % (expected_path, new_name)):
found_plugin = True
if not found_plugin:
print("%s:%d:%d: Can't find '%s/%s.py' in %s.%s" %
(path, 0, 0, plugin_type, new_name, namespace, collection))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment