mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-07 08:54:01 -07:00
Add aggregate for junos modules and sub spec validation (#27726)
* Add aggregate for junos modules and sub spec validation * aggregate support of junos modules * aggregate sub spec validation * relevant changes to junos integration test * junos module boilerplate changes * Add new boilerplate for junos modules * Fix CI issues
This commit is contained in:
parent
6d59ac1bb4
commit
d3e5d30f7c
32 changed files with 1696 additions and 508 deletions
|
@ -1,20 +1,12 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
|
@ -122,6 +114,18 @@ EXAMPLES = """
|
|||
junos_user:
|
||||
name: ansible
|
||||
purge: yes
|
||||
|
||||
- name: Create list of users
|
||||
junos_user:
|
||||
aggregate:
|
||||
- {name: test_user1, full_name: test_user2, role: operator, state: present}
|
||||
- {name: test_user2, full_name: test_user2, role: read-only, state: present}
|
||||
|
||||
- name: Delete list of users
|
||||
junos_user:
|
||||
aggregate:
|
||||
- {name: test_user1, full_name: test_user2, role: operator, state: absent}
|
||||
- {name: test_user2, full_name: test_user2, role: read-only, state: absent}
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
@ -251,26 +255,35 @@ def map_params_to_obj(module):
|
|||
def main():
|
||||
""" main entry point for module execution
|
||||
"""
|
||||
argument_spec = dict(
|
||||
aggregate=dict(type='list', aliases=['collection', 'users']),
|
||||
element_spec = dict(
|
||||
name=dict(),
|
||||
|
||||
full_name=dict(),
|
||||
role=dict(choices=ROLES, default='unauthorized'),
|
||||
sshkey=dict(),
|
||||
|
||||
purge=dict(type='bool'),
|
||||
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
active=dict(default=True, type='bool')
|
||||
)
|
||||
|
||||
mutually_exclusive = [('aggregate', 'name')]
|
||||
argument_spec = dict(
|
||||
aggregate=dict(type='list', elements='dict', options=element_spec, aliases=['collection', 'users']),
|
||||
purge=dict(default=False, type='bool')
|
||||
)
|
||||
|
||||
argument_spec.update(element_spec)
|
||||
argument_spec.update(junos_argument_spec)
|
||||
|
||||
required_one_of = [['aggregate', 'name']]
|
||||
mutually_exclusive = [['aggregate', 'name'],
|
||||
['aggregate', 'full_name'],
|
||||
['aggregate', 'sshkey'],
|
||||
['aggregate', 'state'],
|
||||
['aggregate', 'active']]
|
||||
|
||||
argument_spec.update(junos_argument_spec)
|
||||
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
mutually_exclusive=mutually_exclusive,
|
||||
required_one_of=required_one_of,
|
||||
supports_check_mode=True)
|
||||
|
||||
warnings = list()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue