mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
c8d287fece
* Initial commit Query an organization within Meraki. No support is in place for managing or creating yet * Change output_level method and make the state parameter required. * Implemented listing all organizations - Updated documentation - Parse results and return all organizations - Parse results and return specified organization * Framework for creating an organization - Documentation example for organization creation - Framework exists for creating organizations, pending PR 36809 - Created functions for HTTP calls - Renamed from dashboard.meraki.com to api.meraki.com - Added required_if for state * Remove absent state - Meraki API does not support deleting an organization so absent is removed - Updated documentation to call it state instead of status * Small change to documentation * Support all parameters associated to organization - Added all parameters needed for all organization actions. - None of the added ones work at this time. - Added documentation for clone. * Integration test for meraki_organization module * Rename module to meraki for porting to module utility * Meraki documentation fragment - Created initial documentation fragment for Meraki modules * Add meraki module utility to branch. Formerly was on a separate branch. * CRU support for Meraki organization module * CRU is supported for Meraki organizations * There is no DELETE function for organizations in the API * This code is very messy and needs cleanup * Create and Update actions don't show status as updated, must fix * Added Meraki module utility to module utility documentation list * Added support for organization cloning * Renamed use_ssl to use_https * Removed define_method() * Removed is_org() * Added is_org_valid() which does all org sanity checks * Fixes for ansibot - Changed default of use_proxy from true to false - Removed some commented out code - Updated documentation * Changes for ansibot - Removed requirement for state parameter. I may readd this. - Updated formatting diff --git a/lib/ansible/module_utils/network/meraki/meraki.py b/lib/ansible/module_utils/network/meraki/meraki.py index 3acd3d1038..395ac7c4b4 100644 --- a/lib/ansible/module_utils/network/meraki/meraki.py +++ b/lib/ansible/module_utils/network/meraki/meraki.py @@ -42,7 +42,7 @@ def meraki_argument_spec(): return dict(auth_key=dict(type='str', no_log=True, fallback=(env_fallback, ['MERAKI_KEY'])), host=dict(type='str', default='api.meraki.com'), name=dict(type='str'), - state=dict(type='str', choices=['present', 'absent', 'query'], required=True), + state=dict(type='str', choices=['present', 'absent', 'query']), use_proxy=dict(type='bool', default=False), use_https=dict(type='bool', default=True), validate_certs=dict(type='bool', default=True), diff --git a/lib/ansible/modules/network/meraki/meraki_organization.py b/lib/ansible/modules/network/meraki/meraki_organization.py index 923d969366..3789be91d6 100644 --- a/lib/ansible/modules/network/meraki/meraki_organization.py +++ b/lib/ansible/modules/network/meraki/meraki_organization.py @@ -20,11 +20,9 @@ short_description: Manage organizations in the Meraki cloud version_added: "2.6" description: - Allows for creation, management, and visibility into organizations within Meraki - notes: - More information about the Meraki API can be found at U(https://dashboard.meraki.com/api_docs). - Some of the options are likely only used for developers within Meraki - options: name: description: @@ -32,21 +30,18 @@ options: - If C(clone) is specified, C(name) is the name of the new organization. state: description: - - Create or query organizations - choices: ['query', 'present'] + - Create or modify an organization + choices: ['present', 'query'] clone: description: - Organization to clone to a new organization. - type: string org_name: description: - Name of organization. - Used when C(name) should refer to another object. - type: string org_id: description: - ID of organization - author: - Kevin Breit (@kbreit) extends_documentation_fragment: meraki @@ -86,7 +81,6 @@ RETURN = ''' response: description: Data returned from Meraki dashboard. type: dict - state: query returned: info ''' @@ -103,6 +97,7 @@ def main(): argument_spec = meraki_argument_spec() argument_spec.update(clone=dict(type='str'), + state=dict(type='str', choices=['present', 'query']), ) @@ -125,11 +120,9 @@ def main(): meraki.function = 'organizations' meraki.params['follow_redirects'] = 'all' - meraki.required_if=[ - ['state', 'present', ['name']], - ['clone', ['name']], - # ['vpn_PublicIP', ['name']], - ] + meraki.required_if = [['state', 'present', ['name']], + ['clone', ['name']], + ] create_urls = {'organizations': '/organizations', } @@ -162,23 +155,16 @@ def main(): - - # method = None - # org_id = None - - - # meraki.fail_json(msg=meraki.is_org_valid(meraki.get_orgs(), org_name='AnsibleTestOrg')) - if meraki.params['state'] == 'query': - if meraki.params['name'] is None: # Query all organizations, no matter what - orgs = meraki.get_orgs() - meraki.result['organization'] = orgs - elif meraki.params['name'] is not None: # Query by organization name - module.warn('All matching organizations will be returned, even if there are duplicate named organizations') - orgs = meraki.get_orgs() - for o in orgs: - if o['name'] == meraki.params['name']: - meraki.result['organization'] = o + if meraki.params['name'] is None: # Query all organizations, no matter what + orgs = meraki.get_orgs() + meraki.result['organization'] = orgs + elif meraki.params['name'] is not None: # Query by organization name + module.warn('All matching organizations will be returned, even if there are duplicate named organizations') + orgs = meraki.get_orgs() + for o in orgs: + if o['name'] == meraki.params['name']: + meraki.result['organization'] = o elif meraki.params['state'] == 'present': if meraki.params['clone'] is not None: # Cloning payload = {'name': meraki.params['name']} @@ -193,7 +179,10 @@ def main(): payload = {'name': meraki.params['name'], 'id': meraki.params['org_id'], } - meraki.result['response'] = json.loads(meraki.request(meraki.construct_path('update', org_id=meraki.params['org_id']), payload=json.dumps(payload), method='PUT')) + meraki.result['response'] = json.loads(meraki.request(meraki.construct_path('update', + org_id=meraki.params['org_id']), + payload=json.dumps(payload), + method='PUT')) diff --git a/lib/ansible/utils/module_docs_fragments/meraki.py b/lib/ansible/utils/module_docs_fragments/meraki.py index e268d02e68..3569d83b99 100644 --- a/lib/ansible/utils/module_docs_fragments/meraki.py +++ b/lib/ansible/utils/module_docs_fragments/meraki.py @@ -35,6 +35,7 @@ options: description: - Set amount of debug output during module execution choices: ['normal', 'debug'] + default: 'normal' timeout: description: - Time to timeout for HTTP requests. diff --git a/test/integration/targets/meraki_organization/aliases b/test/integration/targets/meraki_organization/aliases new file mode 100644 index 0000000000..ad7ccf7ada --- /dev/null +++ b/test/integration/targets/meraki_organization/aliases @@ -0,0 +1 @@ +unsupported * Formatting fix * Minor updates due to testing - Made state required again - Improved formatting for happier PEP8 - request() now sets instance method * Fix reporting of the result * Enhance idempotency checks - Remove merging functionality as the proposed should be used - Do check and reverse check to look for differences * Rewrote and added additional integration tests. This isn't done. * Updated is_update_required method: - Original and proposed data is passed to method - Added ignored_keys list so it can be skipped if needed * Changes per comments from dag - Optionally assign function on class instantiation - URLs now have {} for substitution method - Move auth_key check to module utility - Remove is_new and get_existing - Minor changes to documentation * Enhancements for future modules and organization - Rewrote construct_path method for simplicity - Increased support for network functionality to be committed * Changes based on Dag feedback and to debug problems * Minor fixes for validitation testing * Small changes for dag and Ansibot - Changed how auth_key is processed - Removed some commented lines - Updated documentation fragment, but that may get reverted * Remove blank line and comment * Improvements for testing and code simplification - Added network integration tests - Modified error handling in request() - More testing to come on this - Rewrote construct_path again. Very simple now. * Remove trailing whitespace * Small changes based on dag's response * Removed certain sections from exit_json and fail_json as they're old |
||
---|---|---|
.github | ||
bin | ||
changelogs/fragments | ||
contrib | ||
docs | ||
examples | ||
hacking | ||
lib/ansible | ||
licenses | ||
packaging | ||
test | ||
ticket_stubs | ||
.coveragerc | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
.mailmap | ||
.yamllint | ||
ansible-core-sitemap.xml | ||
CHANGELOG.md | ||
CODING_GUIDELINES.md | ||
CONTRIBUTING.md | ||
COPYING | ||
docsite_requirements.txt | ||
Makefile | ||
MANIFEST.in | ||
MODULE_GUIDELINES.md | ||
README.rst | ||
RELEASES.txt | ||
requirements.txt | ||
ROADMAP.rst | ||
setup.py | ||
shippable.yml | ||
tox.ini | ||
VERSION |
|PyPI version| |Docs badge| |Build Status| ******* Ansible ******* Ansible is a radically simple IT automation system. It handles configuration-management, application deployment, cloud provisioning, ad-hoc task-execution, and multinode orchestration -- including trivializing things like zero-downtime rolling updates with load balancers. Read the documentation and more at https://ansible.com/ You can find installation instructions `here <https://docs.ansible.com/intro_getting_started.html>`_ for a variety of platforms. Most users should probably install a released version of Ansible from ``pip``, a package manager or our `release repository <https://releases.ansible.com/ansible/>`_. `Officially supported <https://www.ansible.com/ansible-engine>`_ builds of Ansible are also available. Some power users run directly from the development branch - while significant efforts are made to ensure that ``devel`` is reasonably stable, you're more likely to encounter breaking changes when running Ansible this way. Design Principles ================= * Have a dead simple setup process and a minimal learning curve * Manage machines very quickly and in parallel * Avoid custom-agents and additional open ports, be agentless by leveraging the existing SSH daemon * Describe infrastructure in a language that is both machine and human friendly * Focus on security and easy auditability/review/rewriting of content * Manage new remote machines instantly, without bootstrapping any software * Allow module development in any dynamic language, not just Python * Be usable as non-root * Be the easiest IT automation system to use, ever. Get Involved ============ * Read `Community Information <https://docs.ansible.com/community.html>`_ for all kinds of ways to contribute to and interact with the project, including mailing list information and how to submit bug reports and code to Ansible. * All code submissions are done through pull requests. Take care to make sure no merge commits are in the submission, and use ``git rebase`` vs ``git merge`` for this reason. If submitting a large code change (other than modules), it's probably a good idea to join ansible-devel and talk about what you would like to do or add first to avoid duplicate efforts. This not only helps everyone know what's going on, it also helps save time and effort if we decide some changes are needed. * Users list: `ansible-project <https://groups.google.com/group/ansible-project>`_ * Development list: `ansible-devel <https://groups.google.com/group/ansible-devel>`_ * Announcement list: `ansible-announce <https://groups.google.com/group/ansible-announce>`_ -- read only * irc.freenode.net: #ansible Branch Info =========== * Releases are named after Led Zeppelin songs. (Releases prior to 2.0 were named after Van Halen songs.) * The devel branch corresponds to the release actively under development. * Various release-X.Y branches exist for previous releases. * We'd love to have your contributions, read `Community Information <https://docs.ansible.com/community.html>`_ for notes on how to get started. Authors ======= Ansible was created by `Michael DeHaan <https://github.com/mpdehaan>`_ (michael.dehaan/gmail/com) and has contributions from over 1000 users (and growing). Thanks everyone! Ansible is sponsored by `Ansible, Inc <https://ansible.com>`_ License ======= GNU General Public License v3.0 See `COPYING <COPYING>`_ to see the full text. .. |PyPI version| image:: https://img.shields.io/pypi/v/ansible.svg :target: https://pypi.org/project/ansible .. |Docs badge| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg :target: https://docs.ansible.com/ansible .. |Build Status| image:: https://api.shippable.com/projects/573f79d02a8192902e20e34b/badge?branch=devel :target: https://app.shippable.com/projects/573f79d02a8192902e20e34b