summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/network/junos/junos_lacp.py
blob: e49c43f26341517be5d88f6c2b1faacb05a2f39c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2019 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

#############################################
#                WARNING                    #
#############################################
#
# This file is auto generated by the resource
#   module builder playbook.
#
# Do not edit this file manually.
#
# Changes to this file will be over written
#   by the resource module builder.
#
# Changes should be made in the model used to
#   generate this file or in the resource module
#   builder template.
#
#############################################

"""
The module file for junos_lacp
"""

from __future__ import absolute_import, division, print_function
__metaclass__ = type

ANSIBLE_METADATA = {
    'metadata_version': '1.1',
    'status': ['preview'],
    'supported_by': 'network'
}

DOCUMENTATION = """
---
module: junos_lacp
version_added: 2.9
short_description: Manage Global Link Aggregation Control Protocol (LACP) on Juniper Junos devices
description: This module provides declarative management of global LACP on Juniper Junos network devices.
author: Ganesh Nalawade (@ganeshrn)
options:
  config:
    description: A dictionary of LACP global options
    type: dict
    suboptions:
      system_priority:
        description:
        - LACP priority for the system.
        type: int
      link_protection:
        description:
        - Enable LACP link-protection for the system. If the value is set to C(non-revertive)
          it will not revert links when a better priority link comes up. By default the link will
          be reverted.
        type: str
        choices: ['revertive', 'non-revertive']
  state:
    description:
    - The state of the configuration after module completion
    type: str
    choices:
    - merged
    - replaced
    - deleted
    default: merged
requirements:
  - ncclient (>=v0.6.4)
notes:
  - This module requires the netconf system service be enabled on
    the remote device being managed.
  - Tested against vSRX JUNOS version 18.1R1.
  - This module works with connection C(netconf). See L(the Junos OS Platform Options,../network/user_guide/platform_junos.html).
"""
EXAMPLES = """
# Using deleted

# Before state:
# -------------
# user@junos01# show chassis aggregated-devices ethernet lacp
# system-priority 63;
# link-protection {
#    non-revertive;
# }

- name: Delete global LACP attributes
  junos_lacp:
    state: deleted

# After state:
# ------------
# user@junos01# show chassis aggregated-devices ethernet lacp
#


# Using merged

# Before state:
# -------------
# user@junos01# show chassis aggregated-devices ethernet lacp
#

- name: Merge global LACP attributes
  junos_lacp:
    config:
      system_priority: 63
      link_protection: revertive
    state: merged

# After state:
# ------------
# user@junos01# show chassis aggregated-devices ethernet lacp
# system-priority 63;
# link-protection {
#    non-revertive;
# }


# Using replaced

# Before state:
# -------------
# user@junos01# show chassis aggregated-devices ethernet lacp
# system-priority 63;
# link-protection {
#    non-revertive;
# }

- name: Replace global LACP attributes
  junos_lacp:
    config:
      system_priority: 30
      link_protection: non-revertive
    state: replaced

# After state:
# ------------
# user@junos01# show chassis aggregated-devices ethernet lacp
# system-priority 30;
# link-protection;


"""
RETURN = """
before:
  description: The configuration as structured data prior to module invocation.
  returned: always
  type: dict
  sample: >
    The configuration returned will always be in the same format
     of the parameters above.
after:
  description: The configuration as structured data after module completion.
  returned: when changed
  type: dict
  sample: >
    The configuration returned will always be in the same format
     of the parameters above.
xml:
  description: The set of xml rpc payload pushed to the remote device.
  returned: always
  type: list
  sample: ['xml 1', 'xml 2', 'xml 3']
"""


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.junos.argspec.lacp.lacp import LacpArgs
from ansible.module_utils.network.junos.config.lacp.lacp import Lacp


def main():
    """
    Main entry point for module execution

    :returns: the result form module invocation
    """
    required_if = [('state', 'merged', ('config',)),
                   ('state', 'replaced', ('config',))]

    module = AnsibleModule(argument_spec=LacpArgs.argument_spec,
                           required_if=required_if,
                           supports_check_mode=True)

    result = Lacp(module).execute_module()
    module.exit_json(**result)


if __name__ == '__main__':
    main()