Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save privateip/7ad9a8f5739e26af3352224dd9f0917d to your computer and use it in GitHub Desktop.
Save privateip/7ad9a8f5739e26af3352224dd9f0917d to your computer and use it in GitHub Desktop.
net_vlan
#!/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/>.
#
ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'],
'supported_by': 'core'}
DOCUMENTATION = """
"""
EXAMPLES = """
"""
RETURN = """
"""
import copy
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network_common import EntityCollection
from ansible.module_utils.network_common import to_list
def main():
""" main entry point for module execution
"""
argument_spec = dict(
vlan_id=dict(),
collection=dict(type='list'),
name=dict(),
enabled=dict(type='bool'),
group=dict(default='test'),
purge=dict(type='bool', default=False),
state=dict(default='present', choices=['absent', 'present'])
)
mutually_exclusive = [('username', 'collection')]
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
args = frozenset(['vlan_id', 'name', 'enabled', 'group', 'state'])
keys = frozenset(['vlan_id'])
collection = copy.deepcopy(module.params['collection']) or to_list(module.params)
spec = EntityCollection(module, args=args, keys=keys, from_argspec=True)
data = {
'collection': spec(collection),
'purge': module.params['purge']
}
result = dict(data=data, changed=False)
module.exit_json(**result)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment