Compare commits
87 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1a234c2b2b
|
|||
|
bc80694774
|
|||
|
60af57b585
|
|||
|
cf4ed7c0bb
|
|||
|
e67708d067
|
|||
|
1efc6b8fe7
|
|||
|
f9db71bdb7
|
|||
|
bb21e8d5c6
|
|||
|
e09a7f7d45
|
|||
|
7192063d53
|
|||
|
a51c8ed2ff
|
|||
| 4a3c3cad3d | |||
| 825359ae53 | |||
| 3fb974987c | |||
| 4a8ab6fc84 | |||
| caf10019e2 | |||
| dfe9dea2ca | |||
| 833f589d56 | |||
| 28c9375b0d | |||
| 595021d449 | |||
| 8005080b8b | |||
| 69e0af808a | |||
| 4b3ca96330 | |||
| fc48334d5d | |||
| 2ab3aa04da | |||
| a3858223c6 | |||
| 330364d794 | |||
| 0eeca38493 | |||
| 9d4c436f5b | |||
| 5839ae3046 | |||
| 696dce0192 | |||
| db3d3f15b8 | |||
| d2ee346de5 | |||
| 27a716cc66 | |||
| 29b01f8f53 | |||
| bd62ea5958 | |||
| bd18b12dc9 | |||
| 9702e1c6e0 | |||
| 6eb48873e6 | |||
| 9fa09f26bd | |||
| 3323922fd6 | |||
| 6f0e9788d3 | |||
| 67cc6ad8a5 | |||
| 5afdb44488 | |||
| ded4e9279a | |||
| 047703b743 | |||
| c9f81a1739 | |||
| 07d88cc752 | |||
| e87f15168a | |||
| 7a8f957c3f | |||
| 342fc5e506 | |||
| e27c0430dd | |||
| af4b3cf4f3 | |||
| 0989800e14 | |||
| fad602b095 | |||
| 890892ddd2 | |||
| ea64e8f1e4 | |||
| 28b669fbbe | |||
| 9a76586525 | |||
| 0f9ae148a4 | |||
| 1a126d2c7e | |||
| 19b3b935cd | |||
| 8c8d1f9771 | |||
| 0e5119bc6a | |||
| c794dbe859 | |||
| 793f9f0da3 | |||
| 488aa851bb | |||
| 95beef4561 | |||
|
|
1d8393ef6d | ||
|
|
81bb600d83 | ||
|
|
b641fb8df1 | ||
|
|
508ccc5915 | ||
|
|
72849cbc9f | ||
|
|
eae19320da | ||
|
|
311491a487 | ||
|
|
f2d98f00d7 | ||
|
|
6488751a5c | ||
|
|
97931cbdf8 | ||
|
|
6f6ad047ee | ||
|
|
f5d0ae9730 | ||
|
|
d9e4a0dd0e | ||
|
|
decade8720 | ||
|
|
fa2d28367a | ||
|
|
1a207029eb | ||
|
|
44ce65b1d4 | ||
|
|
b85964015b | ||
|
|
c33a33399f |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -108,6 +108,9 @@ venv.bak/
|
|||||||
# Ansible
|
# Ansible
|
||||||
*.retry
|
*.retry
|
||||||
|
|
||||||
roles/toallab.infrastructure/backup/
|
|
||||||
roles/lightbulb-ansiblered-deck/
|
|
||||||
|
|
||||||
|
.vscode/
|
||||||
|
keys/
|
||||||
|
collections/ansible_collections/
|
||||||
|
.vaultpw
|
||||||
|
context/
|
||||||
|
|||||||
5
.pre-commit-config.yaml
Normal file
5
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
|
rev: v8.18.2
|
||||||
|
hooks:
|
||||||
|
- id: gitleaks
|
||||||
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
1
TODO.txt
Normal file
1
TODO.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Replace alvaroaleman.freeipa-client with https://galaxy.ansible.com/freeipa/ansible_freeipa
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# Note: need to specify extra_vars, providing ansible_ssh_user, and ansible_ssh_pass
|
|
||||||
- name: Set up IPA Client
|
|
||||||
hosts: lab-ipa-client
|
|
||||||
become: yes
|
|
||||||
roles:
|
|
||||||
- role: debian-freeipa-client
|
|
||||||
when: ansible_facts['os_family'] == "Debian"
|
|
||||||
- role: alvaroaleman.freeipa-client
|
|
||||||
when: ansible_facts['os_family'] == "RedHat"
|
|
||||||
|
|
||||||
- name: Set up Basic Lab Packages
|
|
||||||
hosts: all
|
|
||||||
become: yes
|
|
||||||
roles:
|
|
||||||
- role: toal-common
|
|
||||||
10
collections/requirements.yml
Normal file
10
collections/requirements.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
collections:
|
||||||
|
- name: davidban77.gns3
|
||||||
|
- name: netbox.netbox
|
||||||
|
- name: freeipa.ansible_freeipa
|
||||||
|
- name: redhat.satellite
|
||||||
|
- name: community.general
|
||||||
|
- name: redhat.satellite
|
||||||
|
- name: community.crypto
|
||||||
|
- name: onepassword.connect
|
||||||
42
filter_plugins/netbox_filters.py
Normal file
42
filter_plugins/netbox_filters.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# I started this to create a filter that would translate netbox to linux-system-roles/network.
|
||||||
|
|
||||||
|
from ansible.utils.display import Display
|
||||||
|
from ansible.parsing.yaml import dumper
|
||||||
|
display = Display()
|
||||||
|
|
||||||
|
def get_type(intf_type):
|
||||||
|
# This is not ideal. Fix it.
|
||||||
|
# https://github.com/netbox-community/netbox/blob/3eb2d45e8deedfc71cfba9a3c2f919df760b6dca/netbox/dcim/migrations/0082_3569_interface_fields.py
|
||||||
|
if intf_type['id'] == 0:
|
||||||
|
return 'vlan'
|
||||||
|
elif 799 < intf_type['id'] < 2000:
|
||||||
|
return 'ethernet'
|
||||||
|
elif intf_type['id'] == 200:
|
||||||
|
return 'bond'
|
||||||
|
|
||||||
|
|
||||||
|
def translate_interface(interface):
|
||||||
|
|
||||||
|
lsrint = {
|
||||||
|
'name': interface['name'],
|
||||||
|
'interface_name': interface['name'],
|
||||||
|
'state': 'up' if interface['enabled'] else 'down',
|
||||||
|
'persistent_state': 'present' if interface['enabled'] else 'absent',
|
||||||
|
}
|
||||||
|
lsrint['type'] = get_type(interface['type'])
|
||||||
|
|
||||||
|
if lsrint['type'] == "vlan":
|
||||||
|
#Interface name must be in the format <intf>.<vlan>
|
||||||
|
lsrint['parent'] = interface['name'].split('.',1)[0]
|
||||||
|
|
||||||
|
if interface.get('ip_address'):
|
||||||
|
lsrint['ip']['address'] = [ ip['address'] for ip in interface['ip_addresses'] ]
|
||||||
|
|
||||||
|
return lsrint
|
||||||
|
|
||||||
|
def nbint_to_lsr_network(interfaces):
|
||||||
|
return [ translate_interface(netif) for netif in interfaces ]
|
||||||
|
|
||||||
|
class FilterModule(object):
|
||||||
|
def filters(self):
|
||||||
|
return {'nbint_to_lsr_network': nbint_to_lsr_network}
|
||||||
718
library/dnsmadeeasy.py
Normal file
718
library/dnsmadeeasy.py
Normal file
@@ -0,0 +1,718 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright: Ansible Project
|
||||||
|
# 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.1',
|
||||||
|
'status': ['preview'],
|
||||||
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
---
|
||||||
|
module: dnsmadeeasy
|
||||||
|
version_added: "1.3"
|
||||||
|
short_description: Interface with dnsmadeeasy.com (a DNS hosting service).
|
||||||
|
description:
|
||||||
|
- >
|
||||||
|
Manages DNS records via the v2 REST API of the DNS Made Easy service. It handles records only; there is no manipulation of domains or
|
||||||
|
monitor/account support yet. See: U(https://www.dnsmadeeasy.com/integration/restapi/)
|
||||||
|
options:
|
||||||
|
account_key:
|
||||||
|
description:
|
||||||
|
- Account API Key.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
account_secret:
|
||||||
|
description:
|
||||||
|
- Account Secret Key.
|
||||||
|
required: true
|
||||||
|
|
||||||
|
domain:
|
||||||
|
description:
|
||||||
|
- Domain to work with. Can be the domain name (e.g. "mydomain.com") or the numeric ID of the domain in DNS Made Easy (e.g. "839989") for faster
|
||||||
|
resolution
|
||||||
|
required: true
|
||||||
|
|
||||||
|
sandbox:
|
||||||
|
description:
|
||||||
|
- Decides if the sandbox API should be used. Otherwise (default) the production API of DNS Made Easy is used.
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
|
version_added: 2.7
|
||||||
|
|
||||||
|
record_name:
|
||||||
|
description:
|
||||||
|
- Record name to get/create/delete/update. If record_name is not specified; all records for the domain will be returned in "result" regardless
|
||||||
|
of the state argument.
|
||||||
|
|
||||||
|
record_type:
|
||||||
|
description:
|
||||||
|
- Record type.
|
||||||
|
choices: [ 'A', 'AAAA', 'CNAME', 'ANAME', 'HTTPRED', 'MX', 'NS', 'PTR', 'SRV', 'TXT' ]
|
||||||
|
|
||||||
|
record_value:
|
||||||
|
description:
|
||||||
|
- >
|
||||||
|
Record value. HTTPRED: <redirection URL>, MX: <priority> <target name>, NS: <name server>, PTR: <target name>,
|
||||||
|
SRV: <priority> <weight> <port> <target name>, TXT: <text value>"
|
||||||
|
- >
|
||||||
|
If record_value is not specified; no changes will be made and the record will be returned in 'result'
|
||||||
|
(in other words, this module can be used to fetch a record's current id, type, and ttl)
|
||||||
|
|
||||||
|
record_ttl:
|
||||||
|
description:
|
||||||
|
- record's "Time to live". Number of seconds the record remains cached in DNS servers.
|
||||||
|
default: 1800
|
||||||
|
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- whether the record should exist or not
|
||||||
|
required: true
|
||||||
|
choices: [ 'present', 'absent' ]
|
||||||
|
|
||||||
|
validate_certs:
|
||||||
|
description:
|
||||||
|
- If C(no), SSL certificates will not be validated. This should only be used
|
||||||
|
on personally controlled sites using self-signed certificates.
|
||||||
|
type: bool
|
||||||
|
default: 'yes'
|
||||||
|
version_added: 1.5.1
|
||||||
|
|
||||||
|
monitor:
|
||||||
|
description:
|
||||||
|
- If C(yes), add or change the monitor. This is applicable only for A records.
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
systemDescription:
|
||||||
|
description:
|
||||||
|
- Description used by the monitor.
|
||||||
|
required: true
|
||||||
|
default: ''
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
maxEmails:
|
||||||
|
description:
|
||||||
|
- Number of emails sent to the contact list by the monitor.
|
||||||
|
required: true
|
||||||
|
default: 1
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
protocol:
|
||||||
|
description:
|
||||||
|
- Protocol used by the monitor.
|
||||||
|
required: true
|
||||||
|
default: 'HTTP'
|
||||||
|
choices: ['TCP', 'UDP', 'HTTP', 'DNS', 'SMTP', 'HTTPS']
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
port:
|
||||||
|
description:
|
||||||
|
- Port used by the monitor.
|
||||||
|
required: true
|
||||||
|
default: 80
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
sensitivity:
|
||||||
|
description:
|
||||||
|
- Number of checks the monitor performs before a failover occurs where Low = 8, Medium = 5,and High = 3.
|
||||||
|
required: true
|
||||||
|
default: 'Medium'
|
||||||
|
choices: ['Low', 'Medium', 'High']
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
contactList:
|
||||||
|
description:
|
||||||
|
- Name or id of the contact list that the monitor will notify.
|
||||||
|
- The default C('') means the Account Owner.
|
||||||
|
required: true
|
||||||
|
default: ''
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
httpFqdn:
|
||||||
|
description:
|
||||||
|
- The fully qualified domain name used by the monitor.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
httpFile:
|
||||||
|
description:
|
||||||
|
- The file at the Fqdn that the monitor queries for HTTP or HTTPS.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
httpQueryString:
|
||||||
|
description:
|
||||||
|
- The string in the httpFile that the monitor queries for HTTP or HTTPS.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
failover:
|
||||||
|
description:
|
||||||
|
- If C(yes), add or change the failover. This is applicable only for A records.
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
autoFailover:
|
||||||
|
description:
|
||||||
|
- If true, fallback to the primary IP address is manual after a failover.
|
||||||
|
- If false, fallback to the primary IP address is automatic after a failover.
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
ip1:
|
||||||
|
description:
|
||||||
|
- Primary IP address for the failover.
|
||||||
|
- Required if adding or changing the monitor or failover.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
ip2:
|
||||||
|
description:
|
||||||
|
- Secondary IP address for the failover.
|
||||||
|
- Required if adding or changing the failover.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
ip3:
|
||||||
|
description:
|
||||||
|
- Tertiary IP address for the failover.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
ip4:
|
||||||
|
description:
|
||||||
|
- Quaternary IP address for the failover.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
ip5:
|
||||||
|
description:
|
||||||
|
- Quinary IP address for the failover.
|
||||||
|
version_added: 2.4
|
||||||
|
|
||||||
|
notes:
|
||||||
|
- The DNS Made Easy service requires that machines interacting with the API have the proper time and timezone set. Be sure you are within a few
|
||||||
|
seconds of actual time by using NTP.
|
||||||
|
- This module returns record(s) and monitor(s) in the "result" element when 'state' is set to 'present'.
|
||||||
|
These values can be be registered and used in your playbooks.
|
||||||
|
- Only A records can have a monitor or failover.
|
||||||
|
- To add failover, the 'failover', 'autoFailover', 'port', 'protocol', 'ip1', and 'ip2' options are required.
|
||||||
|
- To add monitor, the 'monitor', 'port', 'protocol', 'maxEmails', 'systemDescription', and 'ip1' options are required.
|
||||||
|
- The monitor and the failover will share 'port', 'protocol', and 'ip1' options.
|
||||||
|
|
||||||
|
requirements: [ hashlib, hmac ]
|
||||||
|
author: "Brice Burgess (@briceburg)"
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = '''
|
||||||
|
# fetch my.com domain records
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
register: response
|
||||||
|
|
||||||
|
# create / ensure the presence of a record
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
|
||||||
|
# update the previously created record
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_value: 192.0.2.23
|
||||||
|
|
||||||
|
# fetch a specific record
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
register: response
|
||||||
|
|
||||||
|
# delete a record / ensure it is absent
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
record_type: A
|
||||||
|
state: absent
|
||||||
|
record_name: test
|
||||||
|
|
||||||
|
# Add a failover
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
failover: True
|
||||||
|
ip1: 127.0.0.2
|
||||||
|
ip2: 127.0.0.3
|
||||||
|
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
failover: True
|
||||||
|
ip1: 127.0.0.2
|
||||||
|
ip2: 127.0.0.3
|
||||||
|
ip3: 127.0.0.4
|
||||||
|
ip4: 127.0.0.5
|
||||||
|
ip5: 127.0.0.6
|
||||||
|
|
||||||
|
# Add a monitor
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
monitor: yes
|
||||||
|
ip1: 127.0.0.2
|
||||||
|
protocol: HTTP # default
|
||||||
|
port: 80 # default
|
||||||
|
maxEmails: 1
|
||||||
|
systemDescription: Monitor Test A record
|
||||||
|
contactList: my contact list
|
||||||
|
|
||||||
|
# Add a monitor with http options
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
monitor: yes
|
||||||
|
ip1: 127.0.0.2
|
||||||
|
protocol: HTTP # default
|
||||||
|
port: 80 # default
|
||||||
|
maxEmails: 1
|
||||||
|
systemDescription: Monitor Test A record
|
||||||
|
contactList: 1174 # contact list id
|
||||||
|
httpFqdn: http://my.com
|
||||||
|
httpFile: example
|
||||||
|
httpQueryString: some string
|
||||||
|
|
||||||
|
# Add a monitor and a failover
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
failover: True
|
||||||
|
ip1: 127.0.0.2
|
||||||
|
ip2: 127.0.0.3
|
||||||
|
monitor: yes
|
||||||
|
protocol: HTTPS
|
||||||
|
port: 443
|
||||||
|
maxEmails: 1
|
||||||
|
systemDescription: monitoring my.com status
|
||||||
|
contactList: emergencycontacts
|
||||||
|
|
||||||
|
# Remove a failover
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
failover: no
|
||||||
|
|
||||||
|
# Remove a monitor
|
||||||
|
- dnsmadeeasy:
|
||||||
|
account_key: key
|
||||||
|
account_secret: secret
|
||||||
|
domain: my.com
|
||||||
|
state: present
|
||||||
|
record_name: test
|
||||||
|
record_type: A
|
||||||
|
record_value: 127.0.0.1
|
||||||
|
monitor: no
|
||||||
|
'''
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# DNSMadeEasy module specific support methods.
|
||||||
|
#
|
||||||
|
|
||||||
|
import json
|
||||||
|
import hashlib
|
||||||
|
import hmac
|
||||||
|
from time import strftime, gmtime
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
from ansible.module_utils.six import string_types
|
||||||
|
|
||||||
|
|
||||||
|
class DME2(object):
|
||||||
|
|
||||||
|
def __init__(self, apikey, secret, domain, sandbox, module):
|
||||||
|
self.module = module
|
||||||
|
|
||||||
|
self.api = apikey
|
||||||
|
self.secret = secret
|
||||||
|
|
||||||
|
if sandbox:
|
||||||
|
self.baseurl = 'https://api.sandbox.dnsmadeeasy.com/V2.0/'
|
||||||
|
self.module.warn(warning="Sandbox is enabled. All actions are made against the URL %s" % self.baseurl)
|
||||||
|
else:
|
||||||
|
self.baseurl = 'https://api.dnsmadeeasy.com/V2.0/'
|
||||||
|
|
||||||
|
self.domain = str(domain)
|
||||||
|
self.domain_map = None # ["domain_name"] => ID
|
||||||
|
self.record_map = None # ["record_name"] => ID
|
||||||
|
self.records = None # ["record_ID"] => <record>
|
||||||
|
self.all_records = None
|
||||||
|
self.contactList_map = None # ["contactList_name"] => ID
|
||||||
|
|
||||||
|
# Lookup the domain ID if passed as a domain name vs. ID
|
||||||
|
if not self.domain.isdigit():
|
||||||
|
self.domain = self.getDomainByName(self.domain)['id']
|
||||||
|
|
||||||
|
self.record_url = 'dns/managed/' + str(self.domain) + '/records'
|
||||||
|
self.monitor_url = 'monitor'
|
||||||
|
self.contactList_url = 'contactList'
|
||||||
|
|
||||||
|
def _headers(self):
|
||||||
|
currTime = self._get_date()
|
||||||
|
hashstring = self._create_hash(currTime)
|
||||||
|
headers = {'x-dnsme-apiKey': self.api,
|
||||||
|
'x-dnsme-hmac': hashstring,
|
||||||
|
'x-dnsme-requestDate': currTime,
|
||||||
|
'content-type': 'application/json'}
|
||||||
|
return headers
|
||||||
|
|
||||||
|
def _get_date(self):
|
||||||
|
return strftime("%a, %d %b %Y %H:%M:%S GMT", gmtime())
|
||||||
|
|
||||||
|
def _create_hash(self, rightnow):
|
||||||
|
return hmac.new(self.secret.encode(), rightnow.encode(), hashlib.sha1).hexdigest()
|
||||||
|
|
||||||
|
def query(self, resource, method, data=None):
|
||||||
|
url = self.baseurl + resource
|
||||||
|
if data and not isinstance(data, string_types):
|
||||||
|
data = urlencode(data)
|
||||||
|
|
||||||
|
response, info = fetch_url(self.module, url, data=data, method=method, headers=self._headers())
|
||||||
|
if info['status'] not in (200, 201, 204):
|
||||||
|
self.module.fail_json(msg="%s returned %s, with body: %s" % (url, info['status'], info['msg']))
|
||||||
|
|
||||||
|
try:
|
||||||
|
return json.load(response)
|
||||||
|
except Exception:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def getDomain(self, domain_id):
|
||||||
|
if not self.domain_map:
|
||||||
|
self._instMap('domain')
|
||||||
|
|
||||||
|
return self.domains.get(domain_id, False)
|
||||||
|
|
||||||
|
def getDomainByName(self, domain_name):
|
||||||
|
if not self.domain_map:
|
||||||
|
self._instMap('domain')
|
||||||
|
|
||||||
|
return self.getDomain(self.domain_map.get(domain_name, 0))
|
||||||
|
|
||||||
|
def getDomains(self):
|
||||||
|
return self.query('dns/managed', 'GET')['data']
|
||||||
|
|
||||||
|
def getRecord(self, record_id):
|
||||||
|
if not self.record_map:
|
||||||
|
self._instMap('record')
|
||||||
|
|
||||||
|
return self.records.get(record_id, False)
|
||||||
|
|
||||||
|
# Try to find a single record matching this one.
|
||||||
|
# How we do this depends on the type of record. For instance, there
|
||||||
|
# can be several MX records for a single record_name while there can
|
||||||
|
# only be a single CNAME for a particular record_name. Note also that
|
||||||
|
# there can be several records with different types for a single name.
|
||||||
|
def getMatchingRecord(self, record_name, record_type, record_value):
|
||||||
|
# Get all the records if not already cached
|
||||||
|
if not self.all_records:
|
||||||
|
self.all_records = self.getRecords()
|
||||||
|
|
||||||
|
if record_type in ["CNAME", "ANAME", "HTTPRED", "PTR"]:
|
||||||
|
for result in self.all_records:
|
||||||
|
if result['name'] == record_name and result['type'] == record_type:
|
||||||
|
return result
|
||||||
|
return False
|
||||||
|
elif record_type in ["A", "AAAA", "MX", "NS", "TXT", "SRV"]:
|
||||||
|
for result in self.all_records:
|
||||||
|
if record_type == "MX":
|
||||||
|
value = record_value.split(" ")[1]
|
||||||
|
elif record_type == "SRV":
|
||||||
|
value = record_value.split(" ")[3]
|
||||||
|
else:
|
||||||
|
value = record_value
|
||||||
|
if result['name'] == record_name and result['type'] == record_type and result['value'] == value:
|
||||||
|
return result
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
raise Exception('record_type not yet supported')
|
||||||
|
|
||||||
|
def getRecords(self):
|
||||||
|
return self.query(self.record_url, 'GET')['data']
|
||||||
|
|
||||||
|
def _instMap(self, type):
|
||||||
|
# @TODO cache this call so it's executed only once per ansible execution
|
||||||
|
map = {}
|
||||||
|
results = {}
|
||||||
|
|
||||||
|
# iterate over e.g. self.getDomains() || self.getRecords()
|
||||||
|
for result in getattr(self, 'get' + type.title() + 's')():
|
||||||
|
|
||||||
|
map[result['name']] = result['id']
|
||||||
|
results[result['id']] = result
|
||||||
|
|
||||||
|
# e.g. self.domain_map || self.record_map
|
||||||
|
setattr(self, type + '_map', map)
|
||||||
|
setattr(self, type + 's', results) # e.g. self.domains || self.records
|
||||||
|
|
||||||
|
def prepareRecord(self, data):
|
||||||
|
return json.dumps(data, separators=(',', ':'))
|
||||||
|
|
||||||
|
def createRecord(self, data):
|
||||||
|
# @TODO update the cache w/ resultant record + id when impleneted
|
||||||
|
return self.query(self.record_url, 'POST', data)
|
||||||
|
|
||||||
|
def updateRecord(self, record_id, data):
|
||||||
|
# @TODO update the cache w/ resultant record + id when impleneted
|
||||||
|
return self.query(self.record_url + '/' + str(record_id), 'PUT', data)
|
||||||
|
|
||||||
|
def deleteRecord(self, record_id):
|
||||||
|
# @TODO remove record from the cache when impleneted
|
||||||
|
return self.query(self.record_url + '/' + str(record_id), 'DELETE')
|
||||||
|
|
||||||
|
def getMonitor(self, record_id):
|
||||||
|
return self.query(self.monitor_url + '/' + str(record_id), 'GET')
|
||||||
|
|
||||||
|
def updateMonitor(self, record_id, data):
|
||||||
|
return self.query(self.monitor_url + '/' + str(record_id), 'PUT', data)
|
||||||
|
|
||||||
|
def prepareMonitor(self, data):
|
||||||
|
return json.dumps(data, separators=(',', ':'))
|
||||||
|
|
||||||
|
def getContactList(self, contact_list_id):
|
||||||
|
if not self.contactList_map:
|
||||||
|
self._instMap('contactList')
|
||||||
|
|
||||||
|
return self.contactLists.get(contact_list_id, False)
|
||||||
|
|
||||||
|
def getContactlists(self):
|
||||||
|
return self.query(self.contactList_url, 'GET')['data']
|
||||||
|
|
||||||
|
def getContactListByName(self, name):
|
||||||
|
if not self.contactList_map:
|
||||||
|
self._instMap('contactList')
|
||||||
|
|
||||||
|
return self.getContactList(self.contactList_map.get(name, 0))
|
||||||
|
|
||||||
|
# ===========================================
|
||||||
|
# Module execution.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
account_key=dict(required=True),
|
||||||
|
account_secret=dict(required=True, no_log=True),
|
||||||
|
domain=dict(required=True),
|
||||||
|
sandbox=dict(default='no', type='bool'),
|
||||||
|
state=dict(required=True, choices=['present', 'absent']),
|
||||||
|
record_name=dict(required=False),
|
||||||
|
record_type=dict(required=False, choices=[
|
||||||
|
'A', 'AAAA', 'CNAME', 'ANAME', 'HTTPRED', 'MX', 'NS', 'PTR', 'SRV', 'TXT']),
|
||||||
|
record_value=dict(required=False),
|
||||||
|
record_ttl=dict(required=False, default=1800, type='int'),
|
||||||
|
monitor=dict(default='no', type='bool'),
|
||||||
|
systemDescription=dict(default=''),
|
||||||
|
maxEmails=dict(default=1, type='int'),
|
||||||
|
protocol=dict(default='HTTP', choices=['TCP', 'UDP', 'HTTP', 'DNS', 'SMTP', 'HTTPS']),
|
||||||
|
port=dict(default=80, type='int'),
|
||||||
|
sensitivity=dict(default='Medium', choices=['Low', 'Medium', 'High']),
|
||||||
|
contactList=dict(default=None),
|
||||||
|
httpFqdn=dict(required=False),
|
||||||
|
httpFile=dict(required=False),
|
||||||
|
httpQueryString=dict(required=False),
|
||||||
|
failover=dict(default='no', type='bool'),
|
||||||
|
autoFailover=dict(default='no', type='bool'),
|
||||||
|
ip1=dict(required=False),
|
||||||
|
ip2=dict(required=False),
|
||||||
|
ip3=dict(required=False),
|
||||||
|
ip4=dict(required=False),
|
||||||
|
ip5=dict(required=False),
|
||||||
|
validate_certs=dict(default='yes', type='bool'),
|
||||||
|
),
|
||||||
|
required_together=[
|
||||||
|
['record_value', 'record_ttl', 'record_type']
|
||||||
|
],
|
||||||
|
required_if=[
|
||||||
|
['failover', True, ['autoFailover', 'port', 'protocol', 'ip1', 'ip2']],
|
||||||
|
['monitor', True, ['port', 'protocol', 'maxEmails', 'systemDescription', 'ip1']]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
protocols = dict(TCP=1, UDP=2, HTTP=3, DNS=4, SMTP=5, HTTPS=6)
|
||||||
|
sensitivities = dict(Low=8, Medium=5, High=3)
|
||||||
|
|
||||||
|
DME = DME2(module.params["account_key"], module.params[
|
||||||
|
"account_secret"], module.params["domain"], module.params["sandbox"], module)
|
||||||
|
state = module.params["state"]
|
||||||
|
record_name = module.params["record_name"]
|
||||||
|
record_type = module.params["record_type"]
|
||||||
|
record_value = module.params["record_value"]
|
||||||
|
|
||||||
|
# Follow Keyword Controlled Behavior
|
||||||
|
if record_name is None:
|
||||||
|
domain_records = DME.getRecords()
|
||||||
|
if not domain_records:
|
||||||
|
module.fail_json(
|
||||||
|
msg="The requested domain name is not accessible with this api_key; try using its ID if known.")
|
||||||
|
module.exit_json(changed=False, result=domain_records)
|
||||||
|
|
||||||
|
# Fetch existing record + Build new one
|
||||||
|
current_record = DME.getMatchingRecord(record_name, record_type, record_value)
|
||||||
|
new_record = {'name': record_name}
|
||||||
|
for i in ["record_value", "record_type", "record_ttl"]:
|
||||||
|
if not module.params[i] is None:
|
||||||
|
new_record[i[len("record_"):]] = module.params[i]
|
||||||
|
# Special handling for mx record
|
||||||
|
if new_record["type"] == "MX":
|
||||||
|
new_record["mxLevel"] = new_record["value"].split(" ")[0]
|
||||||
|
new_record["value"] = new_record["value"].split(" ")[1]
|
||||||
|
|
||||||
|
# Special handling for SRV records
|
||||||
|
if new_record["type"] == "SRV":
|
||||||
|
new_record["priority"] = new_record["value"].split(" ")[0]
|
||||||
|
new_record["weight"] = new_record["value"].split(" ")[1]
|
||||||
|
new_record["port"] = new_record["value"].split(" ")[2]
|
||||||
|
new_record["value"] = new_record["value"].split(" ")[3]
|
||||||
|
|
||||||
|
# Fetch existing monitor if the A record indicates it should exist and build the new monitor
|
||||||
|
current_monitor = dict()
|
||||||
|
new_monitor = dict()
|
||||||
|
if current_record and current_record['type'] == 'A':
|
||||||
|
current_monitor = DME.getMonitor(current_record['id'])
|
||||||
|
|
||||||
|
# Build the new monitor
|
||||||
|
for i in ['monitor', 'systemDescription', 'protocol', 'port', 'sensitivity', 'maxEmails',
|
||||||
|
'contactList', 'httpFqdn', 'httpFile', 'httpQueryString',
|
||||||
|
'failover', 'autoFailover', 'ip1', 'ip2', 'ip3', 'ip4', 'ip5']:
|
||||||
|
if module.params[i] is not None:
|
||||||
|
if i == 'protocol':
|
||||||
|
# The API requires protocol to be a numeric in the range 1-6
|
||||||
|
new_monitor['protocolId'] = protocols[module.params[i]]
|
||||||
|
elif i == 'sensitivity':
|
||||||
|
# The API requires sensitivity to be a numeric of 8, 5, or 3
|
||||||
|
new_monitor[i] = sensitivities[module.params[i]]
|
||||||
|
elif i == 'contactList':
|
||||||
|
# The module accepts either the name or the id of the contact list
|
||||||
|
contact_list_id = module.params[i]
|
||||||
|
if not contact_list_id.isdigit() and contact_list_id != '':
|
||||||
|
contact_list = DME.getContactListByName(contact_list_id)
|
||||||
|
if not contact_list:
|
||||||
|
module.fail_json(msg="Contact list {0} does not exist".format(contact_list_id))
|
||||||
|
contact_list_id = contact_list.get('id', '')
|
||||||
|
new_monitor['contactListId'] = contact_list_id
|
||||||
|
else:
|
||||||
|
# The module option names match the API field names
|
||||||
|
new_monitor[i] = module.params[i]
|
||||||
|
|
||||||
|
# Compare new record against existing one
|
||||||
|
record_changed = False
|
||||||
|
if current_record:
|
||||||
|
for i in new_record:
|
||||||
|
if str(current_record[i]) != str(new_record[i]):
|
||||||
|
record_changed = True
|
||||||
|
new_record['id'] = str(current_record['id'])
|
||||||
|
|
||||||
|
monitor_changed = False
|
||||||
|
if current_monitor:
|
||||||
|
for i in new_monitor:
|
||||||
|
if str(current_monitor.get(i)) != str(new_monitor[i]):
|
||||||
|
monitor_changed = True
|
||||||
|
|
||||||
|
# Follow Keyword Controlled Behavior
|
||||||
|
if state == 'present':
|
||||||
|
# return the record if no value is specified
|
||||||
|
if "value" not in new_record:
|
||||||
|
if not current_record:
|
||||||
|
module.fail_json(
|
||||||
|
msg="A record with name '%s' does not exist for domain '%s.'" % (record_name, module.params['domain']))
|
||||||
|
module.exit_json(changed=False, result=dict(record=current_record, monitor=current_monitor))
|
||||||
|
|
||||||
|
# create record and monitor as the record does not exist
|
||||||
|
if not current_record:
|
||||||
|
record = DME.createRecord(DME.prepareRecord(new_record))
|
||||||
|
if module.params['monitor']:
|
||||||
|
monitor = DME.updateMonitor(record['id'], DME.prepareMonitor(new_monitor))
|
||||||
|
module.exit_json(changed=True, result=dict(record=record, monitor=monitor))
|
||||||
|
else:
|
||||||
|
module.exit_json(changed=True, result=dict(record=record))
|
||||||
|
|
||||||
|
# update the record
|
||||||
|
updated = False
|
||||||
|
if record_changed:
|
||||||
|
DME.updateRecord(current_record['id'], DME.prepareRecord(new_record))
|
||||||
|
updated = True
|
||||||
|
if monitor_changed:
|
||||||
|
DME.updateMonitor(current_monitor['recordId'], DME.prepareMonitor(new_monitor))
|
||||||
|
updated = True
|
||||||
|
if updated:
|
||||||
|
module.exit_json(changed=True, result=dict(record=new_record, monitor=new_monitor))
|
||||||
|
|
||||||
|
# return the record (no changes)
|
||||||
|
module.exit_json(changed=False, result=dict(record=current_record, monitor=current_monitor))
|
||||||
|
|
||||||
|
elif state == 'absent':
|
||||||
|
changed = False
|
||||||
|
# delete the record (and the monitor/failover) if it exists
|
||||||
|
if current_record:
|
||||||
|
DME.deleteRecord(current_record['id'])
|
||||||
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
|
# record does not exist, return w/o change.
|
||||||
|
module.exit_json(changed=changed)
|
||||||
|
|
||||||
|
else:
|
||||||
|
module.fail_json(
|
||||||
|
msg="'%s' is an unknown value for the state argument" % state)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
23
netbox.yml
23
netbox.yml
@@ -1,23 +0,0 @@
|
|||||||
plugin: netbox
|
|
||||||
validate_certs: False
|
|
||||||
config_context: True
|
|
||||||
group_by:
|
|
||||||
- device_roles
|
|
||||||
|
|
||||||
#query_filters:
|
|
||||||
# - role: core-switch
|
|
||||||
|
|
||||||
#query_filters:
|
|
||||||
# - role: network-edge-router
|
|
||||||
|
|
||||||
# Query filters are passed directly as an argument to the fetching queries.
|
|
||||||
# You can repeat tags in the query string.
|
|
||||||
|
|
||||||
#query_filters:
|
|
||||||
# - role: server
|
|
||||||
# - tag: web
|
|
||||||
# - tag: production
|
|
||||||
|
|
||||||
#compose:
|
|
||||||
# foo: last_updated
|
|
||||||
# bar: display_name
|
|
||||||
22
pi-dhcp.yml
22
pi-dhcp.yml
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Set Up DHCP System
|
|
||||||
hosts: dhcp-server
|
|
||||||
become: true
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: DHCP Daemon is installed
|
|
||||||
apt:
|
|
||||||
name: isc-dhcp-server
|
|
||||||
state: latest
|
|
||||||
notify: Restart DHCPD
|
|
||||||
|
|
||||||
- name: Generate dhcpd.conf
|
|
||||||
template:
|
|
||||||
src: dhcpd.conf.j2
|
|
||||||
dest: "{{ dhcpd_conf_path }}"
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
- name: Restart DHCPD
|
|
||||||
service:
|
|
||||||
name: isc-dhcpd-server
|
|
||||||
state: restarted
|
|
||||||
42
playbooks/bootstrap.yml
Normal file
42
playbooks/bootstrap.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Note: need to specify extra_vars, providing ansible_ssh_user, and ansible_ssh_pass
|
||||||
|
|
||||||
|
- name: Set up IPA Client
|
||||||
|
hosts: tag_ipa_client
|
||||||
|
become: yes
|
||||||
|
collections:
|
||||||
|
- freeipa.ansible_freeipa
|
||||||
|
pre_tasks:
|
||||||
|
- name: Set hostname
|
||||||
|
hostname:
|
||||||
|
name: "{{inventory_hostname}}"
|
||||||
|
|
||||||
|
- name: Attach subscriptions
|
||||||
|
command: '/usr/bin/subscription-manager attach'
|
||||||
|
register: result
|
||||||
|
changed_when:
|
||||||
|
- '"All installed products are covered by valid entitlements. No need to update subscriptions at this time." not in result.stdout'
|
||||||
|
when: ansible_distribution == "RedHat"
|
||||||
|
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: debian-freeipa-client
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
- role: ipaclient
|
||||||
|
state: present
|
||||||
|
when: ansible_os_family == "RedHat"
|
||||||
|
|
||||||
|
- name: Set up Basic Lab Packages
|
||||||
|
hosts: all
|
||||||
|
become: yes
|
||||||
|
roles:
|
||||||
|
- role: toal-common
|
||||||
|
|
||||||
|
- name: Packages
|
||||||
|
hosts: all
|
||||||
|
become: yes
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Host Packages
|
||||||
|
package:
|
||||||
|
state: present
|
||||||
|
name: "{{ host_packages }}"
|
||||||
59
playbooks/build_ansible.yml
Normal file
59
playbooks/build_ansible.yml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
- name: VM Provisioning
|
||||||
|
hosts: tag_ansible:&tag_tower
|
||||||
|
connection: local
|
||||||
|
collections:
|
||||||
|
- redhat.rhv
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: Obtain SSO token from username / password credentials
|
||||||
|
ovirt_auth:
|
||||||
|
url: "{{ ovirt_url }}"
|
||||||
|
username: "{{ ovirt_username }}"
|
||||||
|
password: "{{ ovirt_password }}"
|
||||||
|
|
||||||
|
- name: Disks Created
|
||||||
|
ovirt_disk:
|
||||||
|
auth: "{{ ovirt_auth }}"
|
||||||
|
description: "Boot Disk for {{ inventory_hostname }}"
|
||||||
|
interface: virtio
|
||||||
|
size: 120GiB
|
||||||
|
storage_domain: nas_iscsi
|
||||||
|
bootable: True
|
||||||
|
wait: true
|
||||||
|
name: "{{ inventory_hostname }}_disk0"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: VM Created
|
||||||
|
ovirt_vm:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: Add NIC to VM
|
||||||
|
ovirt_nic:
|
||||||
|
state: present
|
||||||
|
vm:
|
||||||
|
name: mynic
|
||||||
|
interface: e1000
|
||||||
|
mac_address: 00:1a:4a:16:01:56
|
||||||
|
profile: ovirtmgmt
|
||||||
|
network: ovirtmgmt
|
||||||
|
|
||||||
|
- name: Plug NIC to VM
|
||||||
|
redhat.rhv.ovirt_nic:
|
||||||
|
state: plugged
|
||||||
|
vm: myvm
|
||||||
|
name: mynic
|
||||||
|
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Always revoke the SSO token
|
||||||
|
ovirt_auth:
|
||||||
|
state: absent
|
||||||
|
ovirt_auth: "{{ ovirt_auth }}"
|
||||||
|
|
||||||
|
|
||||||
|
# - name: VM Configuration
|
||||||
|
# - name: Automation Platform Installer
|
||||||
|
# - name:
|
||||||
29
playbooks/build_rhel_template.yml
Normal file
29
playbooks/build_rhel_template.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
- name: Create Build Host in Satellite
|
||||||
|
hosts: localhost
|
||||||
|
connection: localhost
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Build Host
|
||||||
|
redhat.satellite.host:
|
||||||
|
architecture: x86_64
|
||||||
|
build: true
|
||||||
|
comment: "RHEL 8 Template"
|
||||||
|
compute_profile: "4c8g"
|
||||||
|
compute_attributes:
|
||||||
|
start: "1"
|
||||||
|
compute_resource: "ToalLab"
|
||||||
|
content_view: "composite-rhel8"
|
||||||
|
domain: "sandbox.toal.ca"
|
||||||
|
enabled: true
|
||||||
|
hostgroup: "RHEL8"
|
||||||
|
lifecycle_environment: "Library"
|
||||||
|
location: "Lab"
|
||||||
|
name: "rhel8build.sandbox.toal.ca"
|
||||||
|
operatingsystem: "RedHat 8.3"
|
||||||
|
organization: "Toal.ca"
|
||||||
|
server_url: "https://satellite1.mgmt.toal.ca/"
|
||||||
|
subnet: "sandbox"
|
||||||
|
username: "{{ satellite_admin_user }}"
|
||||||
|
password: "{{ satellite_admin_pass }}"
|
||||||
|
validate_certs: no
|
||||||
12
playbooks/build_windows_template.yml
Normal file
12
playbooks/build_windows_template.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
- name: Create an ovirt windows template
|
||||||
|
hosts: windows_template_base
|
||||||
|
gather_facts: false
|
||||||
|
connection: local
|
||||||
|
become: false
|
||||||
|
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||||
|
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- oatakan.windows_ovirt_template
|
||||||
233
playbooks/buildvm.yml
Normal file
233
playbooks/buildvm.yml
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
# Playbook to build new VMs in RHV Cluste
|
||||||
|
# Currently only builds RHEL VMs
|
||||||
|
|
||||||
|
# Create Host
|
||||||
|
|
||||||
|
- name: Preflight checks
|
||||||
|
hosts: tag_build
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- site == "sagely_dc"
|
||||||
|
- is_virtual
|
||||||
|
|
||||||
|
- name: Ensure Primary IP exists and is in DNS
|
||||||
|
hosts: tag_build
|
||||||
|
gather_facts: false
|
||||||
|
collections:
|
||||||
|
- netbox.netbox
|
||||||
|
- freeipa.ansible_freeipa
|
||||||
|
- redhat.rhv
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Obtain SSO token for RHV
|
||||||
|
ovirt_auth:
|
||||||
|
url: "{{ ovirt_url }}"
|
||||||
|
username: "{{ ovirt_username }}"
|
||||||
|
insecure: true
|
||||||
|
password: "{{ ovirt_password }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Get unused IP Address from pool
|
||||||
|
netbox_ip_address:
|
||||||
|
netbox_url: "{{ netbox_api }}"
|
||||||
|
netbox_token: "{{ netbox_token }}"
|
||||||
|
data:
|
||||||
|
prefix: 192.168.16.0/20
|
||||||
|
assigned_object:
|
||||||
|
name: eth0
|
||||||
|
virtual_machine: "{{ inventory_hostname }}"
|
||||||
|
state: new
|
||||||
|
register: new_ip
|
||||||
|
when: primary_ip4 is undefined
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
primary_ip4: "{{ new_ip.ip_address.address|ipaddr('address') }}"
|
||||||
|
vm_hostname: "{{ inventory_hostname.split('.')[0] }}"
|
||||||
|
vm_domain: "{{ inventory_hostname.split('.',1)[1] }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
when: primary_ip4 is undefined
|
||||||
|
|
||||||
|
- name: Primary IPv4 Assigned in Netbox
|
||||||
|
netbox_virtual_machine:
|
||||||
|
netbox_url: "{{ netbox_api }}"
|
||||||
|
netbox_token: "{{ netbox_token }}"
|
||||||
|
data:
|
||||||
|
primary_ip4: "{{ primary_ip4 }}"
|
||||||
|
name: "{{ inventory_hostname }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Primary IPv4 Address
|
||||||
|
debug:
|
||||||
|
var: primary_ip4
|
||||||
|
|
||||||
|
- name: Ensure IP Address in IdM
|
||||||
|
ipadnsrecord:
|
||||||
|
records:
|
||||||
|
- name: "{{ vm_hostname }}"
|
||||||
|
zone_name: "{{ vm_domain }}"
|
||||||
|
record_type: A
|
||||||
|
record_value:
|
||||||
|
- "{{ new_ip.ip_address.address|ipaddr('address') }}"
|
||||||
|
create_reverse: true
|
||||||
|
ipaadmin_password: "{{ ipaadmin_password }}"
|
||||||
|
delegate_to: idm1.mgmt.toal.ca
|
||||||
|
|
||||||
|
- name: Create VMs
|
||||||
|
hosts: tag_build
|
||||||
|
connection: local
|
||||||
|
gather_facts: no
|
||||||
|
collections:
|
||||||
|
- netbox.netbox
|
||||||
|
- redhat.rhv
|
||||||
|
vars:
|
||||||
|
# Workaround to get correct venv python interpreter
|
||||||
|
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Basic Disk Profile
|
||||||
|
set_fact:
|
||||||
|
vm_disks:
|
||||||
|
- name: '{{ inventory_hostname }}_boot'
|
||||||
|
bootable: true
|
||||||
|
sparse: true
|
||||||
|
descr: '{{ inventory_hostname }} Boot / Root disk'
|
||||||
|
interface: virtio
|
||||||
|
size: '{{ disk|default(40) }}'
|
||||||
|
state: present
|
||||||
|
storage_domain: "{{ rhv_storage_domain }}"
|
||||||
|
activate: true
|
||||||
|
when: vm_disks is not defined
|
||||||
|
|
||||||
|
- name: Create VM Disks
|
||||||
|
ovirt_disk:
|
||||||
|
auth: '{{ ovirt_auth }}'
|
||||||
|
name: '{{ item.name }}'
|
||||||
|
description: '{{ item.descr }}'
|
||||||
|
interface: '{{ item.interface }}'
|
||||||
|
size: '{{ item.size|int * 1024000 }}'
|
||||||
|
state: '{{ item.state }}'
|
||||||
|
sparse: '{{ item.sparse }}'
|
||||||
|
wait: true
|
||||||
|
storage_domain: '{{ item.storage_domain }}'
|
||||||
|
async: 300
|
||||||
|
poll: 15
|
||||||
|
loop: '{{ vm_disks }}'
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
nb_query_filter: "slug={{ platform }}"
|
||||||
|
- debug: msg='{{ query("netbox.netbox.nb_lookup", "platforms", api_filter=nb_query_filter, api_endpoint=netbox_api, token=netbox_token)[0].value.name }}'
|
||||||
|
|
||||||
|
- name: Create VM in RHV
|
||||||
|
ovirt_vm:
|
||||||
|
auth: '{{ ovirt_auth }}'
|
||||||
|
name: '{{ inventory_hostname }}'
|
||||||
|
state: present
|
||||||
|
memory: '{{ memory }}MiB'
|
||||||
|
memory_guaranteed: '{{ (memory / 2)|int }}MiB'
|
||||||
|
disks: '{{ vm_disks }}'
|
||||||
|
cpu_cores: '{{ vcpus }}'
|
||||||
|
cluster: '{{ cluster }}'
|
||||||
|
# This is ugly Can we do better?
|
||||||
|
operating_system: '{{ query("netbox.netbox.nb_lookup", "platforms", api_filter=nb_query_filter, api_endpoint=netbox_api, token=netbox_token)[0].value.name }}'
|
||||||
|
type: server
|
||||||
|
graphical_console:
|
||||||
|
protocol:
|
||||||
|
- vnc
|
||||||
|
- spice
|
||||||
|
boot_devices:
|
||||||
|
- hd
|
||||||
|
async: 300
|
||||||
|
poll: 15
|
||||||
|
notify: PXE Boot
|
||||||
|
register: vm_result
|
||||||
|
|
||||||
|
- name: Assign NIC
|
||||||
|
ovirt_nic:
|
||||||
|
auth: '{{ ovirt_auth }}'
|
||||||
|
interface: virtio
|
||||||
|
mac_address: '{{ item.mac_address|default(omit) }}'
|
||||||
|
name: '{{ item.name }}'
|
||||||
|
profile: '{{ item.untagged_vlan.name }}'
|
||||||
|
network: '{{ item.untagged_vlan.name }}' # This is fragile
|
||||||
|
state: '{{ (item.enabled == True) |ternary("plugged","unplugged") }}'
|
||||||
|
linked: yes
|
||||||
|
vm: '{{ inventory_hostname }}'
|
||||||
|
loop: '{{ interfaces }}'
|
||||||
|
register: interface_result
|
||||||
|
|
||||||
|
- debug: var=interface_result
|
||||||
|
|
||||||
|
- name: Host configured in Satellite
|
||||||
|
redhat.satellite.host:
|
||||||
|
username: "{{ satellite_admin_user }}"
|
||||||
|
password: "{{ satellite_admin_pass }}"
|
||||||
|
server_url: "{{ satellite_url }}"
|
||||||
|
name: "{{ inventory_hostname }}"
|
||||||
|
hostgroup: "RHEL8/RHEL8 Sandbox"
|
||||||
|
organization: Toal.ca
|
||||||
|
location: Lab
|
||||||
|
ip: "{{ primary_ip4 }}"
|
||||||
|
mac: "{{ interface_result.results[0].nic.mac.address }}" #fragile
|
||||||
|
build: "{{ vm_result.changed |ternary(true,false) }}"
|
||||||
|
validate_certs: no
|
||||||
|
|
||||||
|
- name: Assign interface MACs to Netbox
|
||||||
|
netbox_vm_interface:
|
||||||
|
netbox_url: "{{ netbox_api }}"
|
||||||
|
netbox_token: "{{ netbox_token }}"
|
||||||
|
data:
|
||||||
|
name: "{{ item.nic.name }}"
|
||||||
|
mac_address: "{{ item.nic.mac.address }}"
|
||||||
|
virtual_machine: "{{ inventory_hostname }}"
|
||||||
|
loop: "{{ interface_result.results }}"
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: PXE Boot
|
||||||
|
ovirt_vm:
|
||||||
|
auth: "{{ ovirt_auth }}"
|
||||||
|
name: "{{ inventory_hostname }}"
|
||||||
|
boot_devices:
|
||||||
|
- network
|
||||||
|
state: running
|
||||||
|
register: vm_build_result
|
||||||
|
|
||||||
|
- name: Ensure VM is running and reachable
|
||||||
|
hosts: tag_build
|
||||||
|
gather_facts: no
|
||||||
|
connection: local
|
||||||
|
collections:
|
||||||
|
- redhat.rhv
|
||||||
|
vars:
|
||||||
|
# Hack to work around virtualenv python interpreter
|
||||||
|
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: VM is running
|
||||||
|
ovirt_vm:
|
||||||
|
auth: "{{ ovirt_auth }}"
|
||||||
|
name: "{{ inventory_hostname }}"
|
||||||
|
state: running
|
||||||
|
boot_devices:
|
||||||
|
- hd
|
||||||
|
|
||||||
|
- name: Wait for SSH to be ready
|
||||||
|
wait_for_connection:
|
||||||
|
timeout: 1800
|
||||||
|
sleep: 5
|
||||||
|
|
||||||
|
# - name: Ensure IP address is correct in Netbox
|
||||||
|
# netbox_virtual_machine:
|
||||||
|
# data:
|
||||||
|
# name: "{{ inventory_hostname }}"
|
||||||
|
# primary_ip4: "{{ primary_ip4 }}"
|
||||||
|
# netbox_url: "{{ netbox_api }}"
|
||||||
|
# netbox_token: "{{ netbox_token }}"
|
||||||
|
# state: present
|
||||||
|
# delegate_to: localhost
|
||||||
|
|
||||||
|
#TODO: Clear Build tag
|
||||||
33
playbooks/create_host.yml
Normal file
33
playbooks/create_host.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
# Create Host
|
||||||
|
- name: Get IP Address from pool
|
||||||
|
hosts: localhost
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Get unused IP Address from pool
|
||||||
|
netbox.netbox.netbox_ip_address:
|
||||||
|
netbox_url: "{{ netbox_api }}"
|
||||||
|
netbox_token: "{{ netbox_token }}"
|
||||||
|
data:
|
||||||
|
prefix: 192.168.16.0/20
|
||||||
|
state: new
|
||||||
|
register: new_ip
|
||||||
|
|
||||||
|
- debug: var=new_ip
|
||||||
|
|
||||||
|
- name: Create IP Address in IdM
|
||||||
|
freeipa.ansible_freeipa.ipadnsrecord:
|
||||||
|
records:
|
||||||
|
- name: test1
|
||||||
|
zone_name: sandbox.toal.ca
|
||||||
|
record_type: A
|
||||||
|
record_value:
|
||||||
|
- "{{ new_ip.ip_address.address|ipaddr('address') }}"
|
||||||
|
create_reverse: true
|
||||||
|
ipaadmin_password: "{{ ipaadmin_password }}"
|
||||||
|
delegate_to: idm1.mgmt.toal.ca
|
||||||
|
|
||||||
|
# Test Comment
|
||||||
|
# - name: Create Satellite Host
|
||||||
|
# - name: Create RHV VM
|
||||||
|
# - name:
|
||||||
25
playbooks/create_satellite_host.yml
Normal file
25
playbooks/create_satellite_host.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
- name: Create new VM / Host in Satellite
|
||||||
|
hosts: sat6.lab.toal.ca
|
||||||
|
vars:
|
||||||
|
sat6_fqdn: "sat6.lab.toal.ca"
|
||||||
|
sat6_user: "{{ vault_sat6_user }}"
|
||||||
|
sat6_pass: "{{ vault_sat6_pass }}"
|
||||||
|
sat6_organization: "Toal.ca"
|
||||||
|
sat6_fail_on_existing: True
|
||||||
|
sat6_power_on_delay: 60
|
||||||
|
sat6_hosts:
|
||||||
|
#VM
|
||||||
|
- name: "rhel1"
|
||||||
|
host_group: "Lab RHEL Hosts/RHEL 8"
|
||||||
|
location: "Lab"
|
||||||
|
ipv4: "192.168.16.10"
|
||||||
|
domain: "sandbox.toal.ca"
|
||||||
|
comment: "Demo Server"
|
||||||
|
compute_resource: "Home Lab"
|
||||||
|
compute_profile: "2-Medium"
|
||||||
|
parameters:
|
||||||
|
- name: "build_type"
|
||||||
|
value: "httpd"
|
||||||
|
roles:
|
||||||
|
- ahuffman.sat6_create_hosts
|
||||||
46
playbooks/cvpublish.yml
Normal file
46
playbooks/cvpublish.yml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
- name: Publish CVs
|
||||||
|
hosts: satellite1.mgmt.toal.ca
|
||||||
|
vars:
|
||||||
|
sat_env_name: Library
|
||||||
|
sat_org: Toal.ca
|
||||||
|
sat_publish_description: Automated CV Update
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Pre-tasks | Find all CVs
|
||||||
|
redhat.satellite.resource_info:
|
||||||
|
username: "{{ satellite_admin_user }}"
|
||||||
|
password: "{{ satellite_admin_pass }}"
|
||||||
|
server_url: "{{ satellite_url }}"
|
||||||
|
organization: "{{ sat_org }}"
|
||||||
|
resource: content_views
|
||||||
|
validate_certs: no
|
||||||
|
register: raw_list_cvs
|
||||||
|
|
||||||
|
- name: Pre-tasks | Get resource information
|
||||||
|
set_fact:
|
||||||
|
list_all_cvs: "{{ raw_list_cvs['resources'] | json_query(jmesquery) | list }}"
|
||||||
|
vars:
|
||||||
|
jmesquery: "[*].{name: name, composite: composite, id: id}"
|
||||||
|
|
||||||
|
- name: Pre-tasks | Extract list of content views
|
||||||
|
set_fact:
|
||||||
|
sat6_content_views_list: "{{ sat6_content_views_list|default([]) }} + ['{{ item.name }}' ]"
|
||||||
|
loop: "{{ list_all_cvs | reject('search', 'Default Organization View') | list }}"
|
||||||
|
when: item.composite == false
|
||||||
|
|
||||||
|
- name: Publish content
|
||||||
|
redhat.satellite.content_view_version:
|
||||||
|
username: "{{ satellite_admin_user }}"
|
||||||
|
password: "{{ satellite_admin_pass }}"
|
||||||
|
server_url: "{{ satellite_url }}"
|
||||||
|
organization: "{{ sat_org }}"
|
||||||
|
content_view: "{{ item }}"
|
||||||
|
validate_certs: no
|
||||||
|
description: "{{ sat_publish_description }}"
|
||||||
|
lifecycle_environments:
|
||||||
|
- Library
|
||||||
|
- "{{ sat_env_name }}"
|
||||||
|
loop: "{{ sat6_content_views_list | list }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: "item"
|
||||||
|
register: cv_publish_sleeper
|
||||||
@@ -5,25 +5,25 @@
|
|||||||
vars:
|
vars:
|
||||||
msg: |
|
msg: |
|
||||||
Module Variables ("vars"):
|
Module Variables ("vars"):
|
||||||
--------------------------
|
--------------------------
|
||||||
{{ vars | to_nice_json }}
|
{{ vars | to_nice_json }}
|
||||||
|
|
||||||
Environment Variables ("environment"):
|
Environment Variables ("environment"):
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
{{ environment | to_nice_json }}
|
{{ environment | to_nice_json }}
|
||||||
|
|
||||||
GROUP NAMES Variables ("group_names"):
|
GROUP NAMES Variables ("group_names"):
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
{{ group_names | to_nice_json }}
|
{{ group_names | to_nice_json }}
|
||||||
|
|
||||||
GROUPS Variables ("groups"):
|
GROUPS Variables ("groups"):
|
||||||
----------------------------
|
----------------------------
|
||||||
{{ groups | to_nice_json }}
|
{{ groups | to_nice_json }}
|
||||||
|
|
||||||
HOST Variables ("hostvars"):
|
HOST Variables ("hostvars"):
|
||||||
----------------------------
|
----------------------------
|
||||||
{{ hostvars | to_nice_json }}
|
{{ hostvars | to_nice_json }}
|
||||||
|
|
||||||
debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ msg.split('\n') }}"
|
msg: "{{ msg.split('\n') }}"
|
||||||
tags: debug_info
|
tags: debug_info
|
||||||
32
playbooks/opnsense.yml
Normal file
32
playbooks/opnsense.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
- name: Get info on the existing host entries
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
module_defaults:
|
||||||
|
group/ansibleguy.opnsense.all:
|
||||||
|
firewall: '{{ lookup("env","OPNSENSE_HOST") }}'
|
||||||
|
api_key: '{{ lookup("env","OPNSENSE_API_KEY") }}'
|
||||||
|
api_secret: '{{ lookup("env","OPNSENSE_API_SECRET") }}'
|
||||||
|
api_port: 8443
|
||||||
|
|
||||||
|
ansibleguy.opnsense.unbound_host:
|
||||||
|
match_fields: ['description']
|
||||||
|
|
||||||
|
ansibleguy.opnsense.list:
|
||||||
|
target: 'unbound_host'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Listing hosts # noqa args[module]
|
||||||
|
ansibleguy.opnsense.list:
|
||||||
|
target: 'unbound_host'
|
||||||
|
register: existing_entries
|
||||||
|
|
||||||
|
- name: Printing entries
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: existing_entries.data
|
||||||
|
|
||||||
|
- name: Generate csv from template
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: ../templates/hosts.j2
|
||||||
|
mode: "0644"
|
||||||
|
dest: "/data/output.csv"
|
||||||
16
playbooks/publish_cvs.yml
Normal file
16
playbooks/publish_cvs.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- name: Publish CVs
|
||||||
|
hosts: sat6.lab.toal.ca
|
||||||
|
connection: local
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Publish Content View
|
||||||
|
redhat.satellite.content_view_version:
|
||||||
|
username: "{{ vault_sat6_user }}"
|
||||||
|
password: "{{ vault_sat6_pass }}"
|
||||||
|
server_url: "https://{{ inventory_hostname }}"
|
||||||
|
validate_certs: false
|
||||||
|
content_view: "RHEL8"
|
||||||
|
organization: "Toal.ca"
|
||||||
|
lifecycle_environments:
|
||||||
|
- Library
|
||||||
316
playbooks/satellite.yml
Normal file
316
playbooks/satellite.yml
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
# Playbook to install Satellite server on RHV
|
||||||
|
|
||||||
|
#TODO: Fix Partitioning, as /var/lib/pulp doesn't get it's own partition now.
|
||||||
|
|
||||||
|
- name: Preflight Setup
|
||||||
|
hosts: "{{ vm_name }}"
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- name: Obtain SSO token from username / password credentials
|
||||||
|
redhat.rhv.ovirt_auth:
|
||||||
|
url: "{{ ovirt_url }}"
|
||||||
|
username: "{{ ovirt_username }}"
|
||||||
|
password: "{{ ovirt_password }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Add host to satellite group
|
||||||
|
add_host:
|
||||||
|
hostname: '{{ vm_name }}'
|
||||||
|
groups: satellite
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Get VM Tags
|
||||||
|
ovirt.ovirt.ovirt_tag_info:
|
||||||
|
vm: "{{ vm_name }}"
|
||||||
|
register: vmtags_result
|
||||||
|
delegate_to: localhost
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Add host to provisioned group
|
||||||
|
add_host:
|
||||||
|
hostname: '{{ vm_name }}'
|
||||||
|
groups: provisioned
|
||||||
|
when:
|
||||||
|
- vmtags_result.ovirt_tags is defined
|
||||||
|
- vmtags_result.ovirt_tags|length > 0
|
||||||
|
- "'provisioned' in vmtags_result.ovirt_tags|map(attribute='name')|list"
|
||||||
|
|
||||||
|
- name: Build VM
|
||||||
|
hosts: "{{ vm_name }}:!provisioned"
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- name: ISO is uploaded to RHV
|
||||||
|
redhat.rhv.ovirt_disk:
|
||||||
|
name: "{{ rhel_iso_filename }}"
|
||||||
|
upload_image_path: "{{ rhel_iso_path }}/{{ rhel_iso_filename }}"
|
||||||
|
storage_domain: ssdvdo0
|
||||||
|
size: 5 GiB
|
||||||
|
wait: true
|
||||||
|
bootable: true
|
||||||
|
format: raw
|
||||||
|
content_type: iso
|
||||||
|
register: iso_disk
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Remove known_hosts entry
|
||||||
|
known_hosts:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- "{{ vm_name }}"
|
||||||
|
- "{{ ansible_host }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Create VM disk
|
||||||
|
ovirt_disk:
|
||||||
|
name: "{{ vm_name }}_Disk0"
|
||||||
|
description: '{{ vm_name }} Primary Disk'
|
||||||
|
interface: 'virtio_scsi'
|
||||||
|
size: '{{ disk }}GiB'
|
||||||
|
state: attached
|
||||||
|
sparse: yes
|
||||||
|
wait: true
|
||||||
|
storage_domain: "ssdvdo0"
|
||||||
|
async: 300
|
||||||
|
poll: 15
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Create Satellite VM in RHV
|
||||||
|
ovirt_vm:
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
state: present
|
||||||
|
memory: "{{ memory}}GiB"
|
||||||
|
disks:
|
||||||
|
- name: "{{ vm_name }}_Disk0"
|
||||||
|
activate: yes
|
||||||
|
bootable: yes
|
||||||
|
cpu_cores: "{{ vcpus }}"
|
||||||
|
cluster: "{{ cluster }}"
|
||||||
|
operating_system: "rhel_7x64"
|
||||||
|
type: server
|
||||||
|
graphical_console:
|
||||||
|
protocol:
|
||||||
|
- vnc
|
||||||
|
boot_devices:
|
||||||
|
- hd
|
||||||
|
async: 300
|
||||||
|
poll: 15
|
||||||
|
register: vm_result
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Assign NIC
|
||||||
|
ovirt_nic:
|
||||||
|
interface: virtio
|
||||||
|
name: nic1
|
||||||
|
profile: ovirtmgmt
|
||||||
|
network: ovirtmgmt
|
||||||
|
state: plugged
|
||||||
|
vm: "{{ vm_name }}"
|
||||||
|
register: nic_result
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Create directory for initial boot files
|
||||||
|
tempfile:
|
||||||
|
state: directory
|
||||||
|
register: kstmpdir
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Extract ISO files
|
||||||
|
community.general.iso_extract:
|
||||||
|
image: "{{ rhel_iso_path }}/{{ rhel_iso_filename }}"
|
||||||
|
dest: "{{ kstmpdir.path }}"
|
||||||
|
files:
|
||||||
|
- isolinux/vmlinuz
|
||||||
|
- isolinux/initrd.img
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Generate Kickstart File
|
||||||
|
template:
|
||||||
|
src: templates/ks.cfg
|
||||||
|
dest: "/var/www/ks/{{ vm_name }}.cfg"
|
||||||
|
become: yes
|
||||||
|
delegate_to: webserver.mgmt.toal.ca
|
||||||
|
|
||||||
|
- name: Temporary Directory
|
||||||
|
file:
|
||||||
|
path: "/tmp/{{ vm_name }}"
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
delegate_to: "{{ vm_host }}"
|
||||||
|
|
||||||
|
- name: Transfer files to Hypervisor
|
||||||
|
copy:
|
||||||
|
src: "{{ hostvars[vm_name].kstmpdir.path }}/{{ item }}"
|
||||||
|
dest: "/tmp/{{ vm_name }}/{{ item }}"
|
||||||
|
loop:
|
||||||
|
- vmlinuz
|
||||||
|
- initrd.img
|
||||||
|
delegate_to: "{{ vm_host }}"
|
||||||
|
|
||||||
|
# NOTE: This is not idempotent
|
||||||
|
- name: First Boot
|
||||||
|
hosts: "{{ vm_name }}:!provisioned"
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: Start VM with first-boot parameters
|
||||||
|
ovirt_vm:
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
host: "{{ vm_host }}"
|
||||||
|
kernel_params_persist: false
|
||||||
|
cd_iso: "{{ iso_disk.id }}"
|
||||||
|
kernel_path: "/tmp/{{ vm_name }}/vmlinuz"
|
||||||
|
kernel_params: "ks=http://192.168.1.199/ks/{{ vm_name }}.cfg inst.stage2=hd:LABEL=RHEL-7.9\\x20Server.x86_64"
|
||||||
|
initrd_path: "/tmp/{{ vm_name }}/initrd.img"
|
||||||
|
state: running
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
|
||||||
|
- name: Wait for system to shut down after installation
|
||||||
|
ovirt_vm_info:
|
||||||
|
pattern: "name={{ vm_name }}"
|
||||||
|
register: vm_info
|
||||||
|
until: vm_info['ovirt_vms'][0]['status'] == "down"
|
||||||
|
delay: 20
|
||||||
|
retries: 60
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
when: hostvars[vm_name].vm_result.vm.status != 'up'
|
||||||
|
|
||||||
|
- name: Power up VM
|
||||||
|
ovirt_vm:
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
state: running
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: VM is running
|
||||||
|
ovirt_vm:
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
state: running
|
||||||
|
boot_devices:
|
||||||
|
- hd
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Set provisioned tag
|
||||||
|
ovirt_tag:
|
||||||
|
name: provisioned
|
||||||
|
vms:
|
||||||
|
- "{{ vm_name }}"
|
||||||
|
state: present
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: OS Preparation
|
||||||
|
hosts: "{{ vm_name }}"
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Set authentication for bootstrap
|
||||||
|
no_log: True
|
||||||
|
set_fact:
|
||||||
|
ansible_ssh_user: "root"
|
||||||
|
ansible_ssh_pass: "{{ initial_root_pass }}"
|
||||||
|
|
||||||
|
- name: Wait for SSH to be ready
|
||||||
|
wait_for_connection:
|
||||||
|
timeout: 1800
|
||||||
|
sleep: 5
|
||||||
|
|
||||||
|
- name: Register System to Red Hat
|
||||||
|
redhat_subscription:
|
||||||
|
state: present
|
||||||
|
username: "{{ rhn_username }}"
|
||||||
|
password: "{{ rhn_password }}"
|
||||||
|
# TODO This shouldn't be hard-coded
|
||||||
|
pool_ids: 8a85f99c727637ad0172e1ba2856736d
|
||||||
|
|
||||||
|
- name: Firewall
|
||||||
|
firewalld:
|
||||||
|
port: "{{ item }}"
|
||||||
|
state: enabled
|
||||||
|
permanent: yes
|
||||||
|
loop:
|
||||||
|
- "80/tcp"
|
||||||
|
- "81/tcp"
|
||||||
|
- "443/tcp"
|
||||||
|
- "5647/tcp"
|
||||||
|
- "8000/tcp"
|
||||||
|
- "8140/tcp"
|
||||||
|
- "9090/tcp"
|
||||||
|
- "53/udp"
|
||||||
|
- "53/tcp"
|
||||||
|
- "67/udp"
|
||||||
|
- "69/udp"
|
||||||
|
- "5000/tcp"
|
||||||
|
notify: Reload Firewall
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: Reload Firewall
|
||||||
|
service:
|
||||||
|
name: firewalld
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Set up IPA Client
|
||||||
|
hosts: "{{ vm_name }}"
|
||||||
|
become: yes
|
||||||
|
vars:
|
||||||
|
ipaclient_realm: IDM.TOAL.CA
|
||||||
|
ipaclient_mkhomedir: true
|
||||||
|
ipaclient_domain: "mgmt.toal.ca"
|
||||||
|
ipaclient_ssh_trust_dns: yes
|
||||||
|
ipaclient_all_ip_addresses: yes
|
||||||
|
|
||||||
|
collections:
|
||||||
|
- freeipa.ansible_freeipa
|
||||||
|
pre_tasks:
|
||||||
|
- name: Hostname is set
|
||||||
|
hostname:
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
roles:
|
||||||
|
- role: ipaclient
|
||||||
|
state: present
|
||||||
|
|
||||||
|
#TODO Automatically set up DNS GSSAPI per: https://access.redhat.com/documentation/en-us/red_hat_satellite/6.8/html/installing_satellite_server_from_a_connected_network/configuring-external-services#configuring-external-idm-dns_satellite
|
||||||
|
|
||||||
|
- name: Set up Basic Lab Packages
|
||||||
|
hosts: "{{ vm_name }}"
|
||||||
|
become: yes
|
||||||
|
roles:
|
||||||
|
- role: toal-common
|
||||||
|
|
||||||
|
- name: Install Satellite Servers
|
||||||
|
hosts: "{{ vm_name }}"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: jjaswanson4.install_satellite.install_satellite
|
||||||
|
|
||||||
|
- name: Configure Satellite Servers
|
||||||
|
hosts: "{{ vm_name }}"
|
||||||
|
collections:
|
||||||
|
- jjaswanson4.configure_satellite
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: include configure_foreman role with katello independent pieces
|
||||||
|
include_role:
|
||||||
|
name: configure_satellite_foreman
|
||||||
|
- name: build satellite by organization
|
||||||
|
include_role:
|
||||||
|
name: configure_satellite_katello
|
||||||
|
loop_control:
|
||||||
|
loop_var: organization
|
||||||
|
loop: "{{ satellite.katello }}"
|
||||||
|
- name: do that again but for katello dependent pieces
|
||||||
|
include_role:
|
||||||
|
name: configure_satellite_foreman
|
||||||
|
vars:
|
||||||
|
requires_katello_content: true
|
||||||
|
|
||||||
|
# - name: Customize Satellite Installation
|
||||||
|
# hosts: "{{ vm_name }}"
|
||||||
|
|
||||||
|
# collections:
|
||||||
|
# - freeipa.ansible_freeipa
|
||||||
|
|
||||||
|
# tasks:
|
||||||
|
# - name:
|
||||||
64
playbooks/site.yml
Normal file
64
playbooks/site.yml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# Toal Lab Site Playbook
|
||||||
|
- name: Common Lab Machine Setup
|
||||||
|
hosts: platform_linux,platform_fedora_linux
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
|
||||||
|
- name: linux-system-roles.network
|
||||||
|
when: network_connections is defined
|
||||||
|
- name: toal-common
|
||||||
|
|
||||||
|
- name: Set Network OS from Netbox info.
|
||||||
|
gather_facts: no
|
||||||
|
hosts: switch01
|
||||||
|
tasks:
|
||||||
|
- name: Set network os type for Cisco
|
||||||
|
set_fact: ansible_network_os="ios"
|
||||||
|
when: "'Cisco IOS' in platforms"
|
||||||
|
|
||||||
|
- name: Configure infrastructure
|
||||||
|
hosts: switch01
|
||||||
|
become_method: enable
|
||||||
|
connection: network_cli
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- toallab.infrastructure
|
||||||
|
|
||||||
|
- name: DHCP Server
|
||||||
|
hosts: service_dhcp
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
# - name: Gather interfaces for dhcp service
|
||||||
|
# set_fact:
|
||||||
|
# dhcp_interfaces:
|
||||||
|
# - name: Gather subnets
|
||||||
|
# set_fact:
|
||||||
|
# subnets: ""
|
||||||
|
# prefixes: "{{ query('netbox.netbox.nb_lookup', 'prefixes', api_endpoint=netbox_api, token=netbox_token) }}"
|
||||||
|
|
||||||
|
# - ip: 192.168.222.0
|
||||||
|
# netmask: 255.255.255.128
|
||||||
|
# domain_name_servers:
|
||||||
|
# - 10.0.2.3
|
||||||
|
# - 10.0.2.4
|
||||||
|
# range_begin: 192.168.222.50
|
||||||
|
# range_end: 192.168.222.127
|
||||||
|
# - ip: 192.168.222.128
|
||||||
|
# default_lease_time: 3600
|
||||||
|
# max_lease_time: 7200
|
||||||
|
# netmask: 255.255.255.128
|
||||||
|
# domain_name_servers: 10.0.2.3
|
||||||
|
# routers: 192.168.222.129
|
||||||
|
roles:
|
||||||
|
- name: sage905.netbox-to-dhcp
|
||||||
|
|
||||||
|
- name: Include Minecraft tasks
|
||||||
|
import_playbook: minecraft.yml
|
||||||
|
|
||||||
|
# - name: Include Gitea tasks
|
||||||
|
# import_playbook: gitea.yml
|
||||||
|
|
||||||
|
# - name: Include Pod Host
|
||||||
|
# include: podhost.yml
|
||||||
23
playbooks/switch_config.yml
Normal file
23
playbooks/switch_config.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
- name: Collect Netbox Data
|
||||||
|
hosts: role_core-switch
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
api_endpoint: "{{ lookup('env','NETBOX_API') }}"
|
||||||
|
api_token: "{{ lookup('env', 'NETBOX_TOKEN') }}"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
# - name: Gather Device Information
|
||||||
|
# set_fact:
|
||||||
|
# device_info: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='name=' + inventory_hostname, api_endpoint=api_endpoint,\
|
||||||
|
# token=api_token )[0] }}"
|
||||||
|
- name: Dump debug info
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: interfaces
|
||||||
|
|
||||||
|
# - name: Obtain list of devices from Netbox
|
||||||
|
# debug:
|
||||||
|
# var: >
|
||||||
|
# "Device {{ item.value.display_name }} (ID: {{ item.key }}) was
|
||||||
|
# manufactured by {{ item.value.device_type.manufacturer.name }}"
|
||||||
|
# loop: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint=api_endpoint, token=api_token ) }}"
|
||||||
15
playbooks/test.yml
Normal file
15
playbooks/test.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- name: Create 1Password Secret
|
||||||
|
hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- onepassword.connect.generic_item:
|
||||||
|
vault_id: "e63n3krpqx7qpohuvlyqpn6m34"
|
||||||
|
title: Lab Secrets Test
|
||||||
|
state: created
|
||||||
|
fields:
|
||||||
|
- label: Codeword
|
||||||
|
value: "hunter2"
|
||||||
|
section: "Personal Info"
|
||||||
|
field_type: concealed
|
||||||
|
# no_log: true
|
||||||
|
register: op_item
|
||||||
16
playbooks/windows_ad.yml
Normal file
16
playbooks/windows_ad.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
- name: Create Windows AD Server
|
||||||
|
hosts: WinAD
|
||||||
|
gather_facts: false
|
||||||
|
connection: local
|
||||||
|
become: false
|
||||||
|
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- oatakan.ansible-role-ovirt
|
||||||
|
|
||||||
|
- name: Configure AD Controller
|
||||||
|
hosts: WinAD
|
||||||
|
become: false
|
||||||
|
- oatakan.ansible-role-windows-ad-controller
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Create RHV/ovirt VLANs
|
|
||||||
hosts: rhv.lab.toal.ca
|
|
||||||
connection: local
|
|
||||||
vars:
|
|
||||||
# Hack to work around virtualenv python interpreter
|
|
||||||
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
|
||||||
tasks:
|
|
||||||
- ovirt_network:
|
|
||||||
auth: "{{ ovirt_auth }}"
|
|
||||||
fetch_nested: true
|
|
||||||
data_center: "{{ item.data_center }}"
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
vlan_tag: "{{ item.vlan_tag }}"
|
|
||||||
vm_network: "{{ item.vm_network }}"
|
|
||||||
mtu: "{{ item.mtu }}"
|
|
||||||
description: "{{ item.description }}"
|
|
||||||
loop: "{{ ovirt_networks }}"
|
|
||||||
register: networkinfo
|
|
||||||
|
|
||||||
- debug: msg="{{networkinfo}}"
|
|
||||||
27
roles/alvaroaleman.freeipa-client/.gitignore
vendored
27
roles/alvaroaleman.freeipa-client/.gitignore
vendored
@@ -1,27 +0,0 @@
|
|||||||
### Files to be ignored by Git ###
|
|
||||||
|
|
||||||
# Ruby
|
|
||||||
Gemfile.lock
|
|
||||||
|
|
||||||
# Vagrant
|
|
||||||
/\.vagrant/
|
|
||||||
|
|
||||||
# IntelliJ IDEA
|
|
||||||
/*\.ipr
|
|
||||||
/*\.iws
|
|
||||||
/\.idea/
|
|
||||||
**/*\.iml
|
|
||||||
|
|
||||||
# Eclipse
|
|
||||||
/\.classpath
|
|
||||||
/\.project
|
|
||||||
/\.settings/
|
|
||||||
|
|
||||||
# Mac
|
|
||||||
**/\.DS_Store
|
|
||||||
|
|
||||||
# Custom
|
|
||||||
/temp/
|
|
||||||
/tmp/
|
|
||||||
envvars
|
|
||||||
*.swp
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
---
|
|
||||||
language: python
|
|
||||||
python: "2.7"
|
|
||||||
before_install:
|
|
||||||
- sudo apt-get update --assume-yes -qq
|
|
||||||
- sudo apt-get install --assume-yes -qq python-apt python-pycurl
|
|
||||||
install:
|
|
||||||
- sudo pip install ansible
|
|
||||||
script:
|
|
||||||
- ansible --version
|
|
||||||
- ansible-playbook --inventory-file tests/hosts --syntax-check tests/playbook.yml
|
|
||||||
- ansible-playbook --inventory-file tests/hosts --connection=local -vvvv tests/playbook.yml
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
Remo Wenger (2):
|
|
||||||
|
|
||||||
* Add support for RHEL
|
|
||||||
* Add RHEL to Requirements
|
|
||||||
|
|
||||||
# 1.3.1
|
|
||||||
|
|
||||||
fxfitz (2):
|
|
||||||
|
|
||||||
* Remove always_run
|
|
||||||
* Use recommended change
|
|
||||||
|
|
||||||
# 1.3.0
|
|
||||||
|
|
||||||
Alvaro Aleman (10):
|
|
||||||
|
|
||||||
* Use complex args style
|
|
||||||
* More style
|
|
||||||
* Fix defaults for Trusty
|
|
||||||
* Fix variable namespace for package var
|
|
||||||
* Update supported distros
|
|
||||||
* Update sample playbook
|
|
||||||
* Set test variables in playbook instead of Vagrantfile
|
|
||||||
* Add assertion for required variables
|
|
||||||
* Update role name in README
|
|
||||||
* Add xenial to supported distros
|
|
||||||
|
|
||||||
Tomas Dobrovolny (4):
|
|
||||||
|
|
||||||
* Make DNS updates optional
|
|
||||||
* Correct syntax using variable packages in with_items
|
|
||||||
* Run Ubuntu specific tasks for all Debians
|
|
||||||
* Add Ubuntu-16 to supported distributions
|
|
||||||
|
|
||||||
# 1.2.0
|
|
||||||
|
|
||||||
Alvaro Aleman (3):
|
|
||||||
|
|
||||||
* Fix changelog ordering
|
|
||||||
* Allow to register all routable client ips on DNS
|
|
||||||
* Dont replace all DNS servers
|
|
||||||
|
|
||||||
# 1.1.0
|
|
||||||
|
|
||||||
Alvaro Aleman (14):
|
|
||||||
|
|
||||||
* Move variables to role-specific namespace
|
|
||||||
* Add consistent role tag
|
|
||||||
* Refactor supported_distribution check for readability
|
|
||||||
* Add Makefile to make testing easier
|
|
||||||
* Make Vagrant not set DNS server by default
|
|
||||||
* Use public ipa server for testing
|
|
||||||
* Fix dependencies
|
|
||||||
* Add no_ntp parameter
|
|
||||||
* Add force_join parameter
|
|
||||||
* Make hostname parameter optional
|
|
||||||
* Fix checkmode
|
|
||||||
* Remove obsolete serverspec testing
|
|
||||||
* Refactor join for readability
|
|
||||||
* Add contribution guidelines
|
|
||||||
|
|
||||||
Casey Labs (2):
|
|
||||||
|
|
||||||
* Update Ubuntu tasks
|
|
||||||
* Adding SSH restart to handlers
|
|
||||||
|
|
||||||
# 1.0.0
|
|
||||||
|
|
||||||
Alvaro Aleman (8):
|
|
||||||
|
|
||||||
* Populate galaxy info
|
|
||||||
* Update documentation
|
|
||||||
* Disable unused Docker testing
|
|
||||||
* Fix naming
|
|
||||||
* Fix Vagrant testing
|
|
||||||
* Add *.swp files to gitignore
|
|
||||||
* Update testing mechanism
|
|
||||||
* init
|
|
||||||
|
|
||||||
# 0.0.1
|
|
||||||
|
|
||||||
* Initial commit
|
|
||||||
|
|
||||||
|
|
||||||
<!-- vim: set nofen ts=4 sw=4 et: -->
|
|
||||||
@@ -1,662 +0,0 @@
|
|||||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 19 November 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU Affero General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works, specifically designed to ensure
|
|
||||||
cooperation with the community in the case of network server software.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
our General Public Licenses are intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
Developers that use our General Public Licenses protect your rights
|
|
||||||
with two steps: (1) assert copyright on the software, and (2) offer
|
|
||||||
you this License which gives you legal permission to copy, distribute
|
|
||||||
and/or modify the software.
|
|
||||||
|
|
||||||
A secondary benefit of defending all users' freedom is that
|
|
||||||
improvements made in alternate versions of the program, if they
|
|
||||||
receive widespread use, become available for other developers to
|
|
||||||
incorporate. Many developers of free software are heartened and
|
|
||||||
encouraged by the resulting cooperation. However, in the case of
|
|
||||||
software used on network servers, this result may fail to come about.
|
|
||||||
The GNU General Public License permits making a modified version and
|
|
||||||
letting the public access it on a server without ever releasing its
|
|
||||||
source code to the public.
|
|
||||||
|
|
||||||
The GNU Affero General Public License is designed specifically to
|
|
||||||
ensure that, in such cases, the modified source code becomes available
|
|
||||||
to the community. It requires the operator of a network server to
|
|
||||||
provide the source code of the modified version running there to the
|
|
||||||
users of that server. Therefore, public use of a modified version, on
|
|
||||||
a publicly accessible server, gives the public access to the source
|
|
||||||
code of the modified version.
|
|
||||||
|
|
||||||
An older license, called the Affero General Public License and
|
|
||||||
published by Affero, was designed to accomplish similar goals. This is
|
|
||||||
a different license, not a version of the Affero GPL, but Affero has
|
|
||||||
released a new version of the Affero GPL which permits relicensing under
|
|
||||||
this license.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, if you modify the
|
|
||||||
Program, your modified version must prominently offer all users
|
|
||||||
interacting with it remotely through a computer network (if your version
|
|
||||||
supports such interaction) an opportunity to receive the Corresponding
|
|
||||||
Source of your version by providing access to the Corresponding Source
|
|
||||||
from a network server at no charge, through some standard or customary
|
|
||||||
means of facilitating copying of software. This Corresponding Source
|
|
||||||
shall include the Corresponding Source for any work covered by version 3
|
|
||||||
of the GNU General Public License that is incorporated pursuant to the
|
|
||||||
following paragraph.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the work with which it is combined will remain governed by version
|
|
||||||
3 of the GNU General Public License.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU Affero General Public License from time to time. Such new versions
|
|
||||||
will be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU Affero General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU Affero General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU Affero General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program 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 Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If your software can interact with users remotely through a computer
|
|
||||||
network, you should also make sure that it provides a way for users to
|
|
||||||
get its source. For example, if your program is a web application, its
|
|
||||||
interface could display a "Source" link that leads users to an archive
|
|
||||||
of the code. There are many ways you could offer source, and different
|
|
||||||
solutions will be better for different programs; see section 13 for the
|
|
||||||
specific requirements.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
LOGFILE = /tmp/ansible-freeipaclient-logfile
|
|
||||||
|
|
||||||
default: test
|
|
||||||
|
|
||||||
clean:
|
|
||||||
- vagrant destroy -f
|
|
||||||
|
|
||||||
box: clean
|
|
||||||
# Start vagrant box
|
|
||||||
vagrant up --no-provision --provider $(ANSIBLE_FREEIPACLIENT_VAGRANT_PROVIDER)
|
|
||||||
|
|
||||||
checkmode:
|
|
||||||
# Test checkmode
|
|
||||||
ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_CHECKMODE=1 vagrant provision
|
|
||||||
|
|
||||||
provision:
|
|
||||||
# Test role
|
|
||||||
vagrant provision
|
|
||||||
|
|
||||||
idempotence:
|
|
||||||
# Idempotence test
|
|
||||||
vagrant provision | tee $(LOGFILE) | grep 'changed=0.*failed=0' || (cat $(LOGFILE) && false)
|
|
||||||
|
|
||||||
|
|
||||||
test: box checkmode provision idempotence
|
|
||||||
make checkmode
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
# ansible-freeipa-client
|
|
||||||
|
|
||||||
## Synopsis
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- hosts: all
|
|
||||||
vars:
|
|
||||||
freeipaclient_server: ipa.demo1.freeipa.org
|
|
||||||
freeipaclient_domain: ipa.demo1.freeipa.org
|
|
||||||
freeipaclient_enroll_user: admin
|
|
||||||
freeipaclient_enroll_pass: Secret123
|
|
||||||
roles:
|
|
||||||
- alvaroaleman.freeipa-client
|
|
||||||
```
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This role allows to join clients to an ipa domain
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
* CentOS 7
|
|
||||||
* Red Hat Enterprise Linux 7
|
|
||||||
* Fedora 24
|
|
||||||
* Ubuntu Trusty
|
|
||||||
* Ubuntu Xenial
|
|
||||||
* Ubuntu Bionic
|
|
||||||
|
|
||||||
## Role Variables
|
|
||||||
|
|
||||||
* ``freeipaclient_server``: IP/Hostname of IPA server to use (string, mandatory)
|
|
||||||
* ``freeipaclient_domain``: Domain to use (string, mandatory)
|
|
||||||
* ``freeipaclient_enroll_user``: Username to enroll host in domain (string, mandatory)
|
|
||||||
* ``freeipaclient_enroll_pass``: Password to enroll host in domain (string, mandatory)
|
|
||||||
* ``freeipaclient_hostname``: The hostname to use for the client (string, default: output of ``uname -n``)
|
|
||||||
* ``freeipaclient_dns_server``: DNS server to configure. This will not do anything if variable is empty (string)
|
|
||||||
* ``freeipaclient_force_join``: Whether to overwrite an already existing host entry of requested name (boolean, default: ``false``)
|
|
||||||
* ``freeipaclient_enable_ntp``: Whether to enable ntp. Kerberos won't work if the time of master and client drift too much (boolean, default: ``true``)
|
|
||||||
* ``freeipaclient_all_ip_addresses``: Whether to add all routable ip addresses to DNS (boolean, default: ``true if not Trusty, else false``)
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
GNU AFFERO GENERAL PUBLIC LICENSE Version 3
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
If you want to contribute to this repository please be aware that this
|
|
||||||
project uses a [gitflow](http://nvie.com/posts/a-successful-git-branching-model/)
|
|
||||||
workflow with the next release branch called ``next``.
|
|
||||||
|
|
||||||
Please fork this repository and create a local branch split off of the ``next``
|
|
||||||
branch and create pull requests back to the origin ``next`` branch.
|
|
||||||
|
|
||||||
## Integration testing
|
|
||||||
|
|
||||||
This role provides integration tests using Vagrant:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp envvars-vagrant.sample envvars
|
|
||||||
EDITOR=vim
|
|
||||||
$EDITOR envvars
|
|
||||||
source envvars
|
|
||||||
make test
|
|
||||||
```
|
|
||||||
|
|
||||||
## Author information
|
|
||||||
|
|
||||||
Alvaro Aleman
|
|
||||||
|
|
||||||
<!-- vim: set nofen ts=4 sw=4 et: -->
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
1.3.4
|
|
||||||
56
roles/alvaroaleman.freeipa-client/Vagrantfile
vendored
56
roles/alvaroaleman.freeipa-client/Vagrantfile
vendored
@@ -1,56 +0,0 @@
|
|||||||
# vim: set ft=ruby ts=2 sw=2 et:
|
|
||||||
# -*- mode: ruby -*-
|
|
||||||
|
|
||||||
|
|
||||||
VAGRANT_API_VERSION = '2'
|
|
||||||
Vagrant.configure(VAGRANT_API_VERSION) do |config|
|
|
||||||
|
|
||||||
if ENV['ANSIBLE_FREEIPACLIENT_VAGRANT_BOXNAME']
|
|
||||||
config.vm.box = ENV['ANSIBLE_FREEIPACLIENT_VAGRANT_BOXNAME']
|
|
||||||
else
|
|
||||||
config.vm.box = 'ubuntu/trusty64'
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.define :ansiblefreeipaclienttest do |d|
|
|
||||||
|
|
||||||
d.vm.hostname = 'ansiblefreeipaclienttest'
|
|
||||||
d.vm.synced_folder '.', '/vagrant', id: 'vagrant-root', disabled: true
|
|
||||||
|
|
||||||
d.vm.provision :ansible do |ansible|
|
|
||||||
ansible.playbook = 'tests/playbook.yml'
|
|
||||||
ansible.tags = ENV['ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_TAGS']
|
|
||||||
ansible.skip_tags = ENV['ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_SKIP_TAGS']
|
|
||||||
ansible.verbose = ENV['ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_VERBOSE']
|
|
||||||
if ENV['ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_CHECKMODE'] == '1'
|
|
||||||
ansible.raw_arguments = '--check'
|
|
||||||
end
|
|
||||||
ansible.groups = {
|
|
||||||
'vagrant' => ['ansiblefreeipaclienttest']
|
|
||||||
}
|
|
||||||
ansible.limit = 'vagrant'
|
|
||||||
ansible.raw_arguments = [
|
|
||||||
'--diff'
|
|
||||||
]
|
|
||||||
if ENV['ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_CHECKMODE'] == '1'
|
|
||||||
ansible.raw_arguments << '--check'
|
|
||||||
end
|
|
||||||
|
|
||||||
::File.directory?('.vagrant/provisioners/ansible/inventory/') do
|
|
||||||
ansible.inventory_path = '.vagrant/provisioners/ansible/inventory/'
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
d.vm.provider :virtualbox do |v|
|
|
||||||
v.customize 'pre-boot', ['modifyvm', :id, '--nictype1', 'virtio']
|
|
||||||
v.customize [ 'modifyvm', :id, '--name', 'ansiblefreeipaclienttest', '--memory', '512', '--cpus', '1' ]
|
|
||||||
end
|
|
||||||
|
|
||||||
d.vm.provider :libvirt do |lv|
|
|
||||||
lv.memory = 1024
|
|
||||||
lv.cpus = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
[defaults]
|
|
||||||
roles_path = ../
|
|
||||||
nocows = 1
|
|
||||||
retry_files_enabled = False
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for ansible-freeipa-client
|
|
||||||
freeipaclient_force_join: false
|
|
||||||
freeipaclient_enable_ntp: true
|
|
||||||
freeipaclient_all_ip_addresses: "{{ true if ansible_distribution_release != 'trusty' else false }}"
|
|
||||||
freeipaclient_enable_dns_updates: true
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# General settings for Vagrant
|
|
||||||
export ANSIBLE_FREEIPACLIENT_VAGRANT_BOXNAME=centos/7 # name of the vagrant box to use for testing
|
|
||||||
export ANSIBLE_FREEIPACLIENT_VAGRANT_PROVIDER=virtualbox # name of the vagrant provider to use for testing
|
|
||||||
#export ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_TAGS= # Multiple tags can be specified comma seperated
|
|
||||||
unset ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_TAGS # An empty tags variable leads to an error
|
|
||||||
#export ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_SKIP_TAGS= # Multiple tags can be specified comma seperated
|
|
||||||
unset ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_SKIP_TAGS # An empty skip_tags variable leads to an error
|
|
||||||
export ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_VERBOSE= # May contain one to four 'v's
|
|
||||||
export ANSIBLE_FREEIPACLIENT_VAGRANT_ANSIBLE_CHECKMODE= # 1 to enable, any other value to disable
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for ansible-freeipa-client
|
|
||||||
#
|
|
||||||
- name: restart sssd
|
|
||||||
tags:
|
|
||||||
- sssd
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
service:
|
|
||||||
name=sssd
|
|
||||||
state=restarted
|
|
||||||
|
|
||||||
- name: restart ssh
|
|
||||||
tags:
|
|
||||||
- sssd
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
service:
|
|
||||||
name=ssh
|
|
||||||
state=restarted
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{install_date: 'Tue Nov 20 16:00:28 2018', version: 1.3.4}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
galaxy_info:
|
|
||||||
author: Alvaro Aleman
|
|
||||||
description: A role to join clients to an IPA domain
|
|
||||||
license: AGPLv3
|
|
||||||
min_ansible_version: 2.1
|
|
||||||
platforms:
|
|
||||||
- name: EL
|
|
||||||
versions:
|
|
||||||
- 7
|
|
||||||
- name: Fedora
|
|
||||||
versions:
|
|
||||||
- 24
|
|
||||||
- name: Ubuntu
|
|
||||||
versions:
|
|
||||||
- trusty
|
|
||||||
- xenial
|
|
||||||
categories:
|
|
||||||
- system
|
|
||||||
- identity
|
|
||||||
- ldap
|
|
||||||
- kerberos
|
|
||||||
dependencies: []
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
##Always exit on $? -ne 0
|
|
||||||
set -e
|
|
||||||
##
|
|
||||||
|
|
||||||
_cleanup()
|
|
||||||
{
|
|
||||||
rm $FILENAME_TMPCHANGELOG &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
##### Create a release for a project managed with a Git repository #####
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Functions ###
|
|
||||||
|
|
||||||
# Confirm dialog for user interactions
|
|
||||||
# Usage: confirm "Question?"
|
|
||||||
# Returns: 0 = true, 1 = false
|
|
||||||
confirm() {
|
|
||||||
read -r -p "$1 [y/n] " response
|
|
||||||
case $response in
|
|
||||||
[yY][eE][sS]|[yY])
|
|
||||||
return 0;;
|
|
||||||
*)
|
|
||||||
return 1;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
### Display usage message
|
|
||||||
usage () {
|
|
||||||
echo "Usage: $0 [-v VERSION] [-r REMOTE] -s 'One line summary of changes for this release'"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
### Initialize the variables and settings ###
|
|
||||||
#Variables
|
|
||||||
RELEASE_VERSION=
|
|
||||||
REMOTE=
|
|
||||||
SHORT_SUMMARY=
|
|
||||||
|
|
||||||
while getopts v:r:s: OPT; do
|
|
||||||
case $OPT in
|
|
||||||
v) RELEASE_VERSION="${OPTARG}";;
|
|
||||||
r) REMOTE="${OPTARG}";;
|
|
||||||
s) SHORT_SUMMARY="${OPTARG}";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift $(( $OPTIND - 1 ));
|
|
||||||
|
|
||||||
if [ -z "${SHORT_SUMMARY}" ]; then
|
|
||||||
usage && exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
: ${REMOTE:=origin}
|
|
||||||
|
|
||||||
FILENAME_TMPCHANGELOG="$( mktemp --suffix=ansible_role_release_changelog )"
|
|
||||||
|
|
||||||
trap _cleanup ALRM HUP INT TERM EXIT
|
|
||||||
|
|
||||||
# Fetch Git remote inormation
|
|
||||||
git fetch $REMOTE --tags
|
|
||||||
|
|
||||||
# Some information can be detected
|
|
||||||
LAST_VERSION=$( git tag -l | tail -n 1 )
|
|
||||||
REPOSITORY_NAME=$( git remote show -n $REMOTE | grep Fetch | sed 's#.*/##' | sed 's/\.git//' )
|
|
||||||
EXISTING_TAGS=`git tag -l`
|
|
||||||
|
|
||||||
# Detect version if not provided by user
|
|
||||||
if [[ -z "${RELEASE_VERSION}" ]]; then
|
|
||||||
RELEASE_VERSION=$(echo $LAST_VERSION|awk -F . '{print $1 "." $2 + 1 "." $3}')
|
|
||||||
fi
|
|
||||||
|
|
||||||
RELEASE_BRANCH="release/${RELEASE_VERSION}"
|
|
||||||
# Check if there is already a tag named $RELEASE_VERSION
|
|
||||||
## Temporary disabling exit on $? -ne 0 to be able to display error message
|
|
||||||
set +e
|
|
||||||
if [[ $EXISTING_TAGS =~ "$RELEASE_VERSION" ]]; then
|
|
||||||
>&2 echo "A tag $RELEASE_VERSION already exists!"
|
|
||||||
>&2 echo "Aborting.."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
set -e
|
|
||||||
|
|
||||||
|
|
||||||
# Confirm or exit
|
|
||||||
echo
|
|
||||||
echo "Settings for the release to be created:"
|
|
||||||
echo " Version of last release: ${LAST_VERSION}"
|
|
||||||
echo " Version of new release: ${RELEASE_VERSION}"
|
|
||||||
echo " Name of Git repository: ${REPOSITORY_NAME}"
|
|
||||||
echo " Summary text for release: ${SHORT_SUMMARY}"
|
|
||||||
if ! confirm "Continue with these settings?"; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Perform release ###
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Checkout and pull next branch"
|
|
||||||
git checkout next
|
|
||||||
git pull $REMOTE next
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Checkout new release branch"
|
|
||||||
git checkout -b ${RELEASE_BRANCH}
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Write VERSION file"
|
|
||||||
echo ${RELEASE_VERSION} > VERSION
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Add release information to CHANGELOG.md file"
|
|
||||||
|
|
||||||
cat CHANGELOG.md > $FILENAME_TMPCHANGELOG
|
|
||||||
echo "# ${RELEASE_VERSION}" > CHANGELOG.md
|
|
||||||
echo "" >> CHANGELOG.md
|
|
||||||
|
|
||||||
if [[ -n ${LAST_VERSION} ]]; then
|
|
||||||
git shortlog --no-merges next --not ${LAST_VERSION} | sed -e '/^[ \t]/s#^[ \t]*#* #' | perl -pe 's/:$/:\n/g' >> CHANGELOG.md
|
|
||||||
cat $FILENAME_TMPCHANGELOG >> CHANGELOG.md
|
|
||||||
else
|
|
||||||
git shortlog --no-merges next | sed -e '/^[ \t]/s#^[ \t]*#* #' | perl -pe 's/:$/:\n/g' >> CHANGELOG.md
|
|
||||||
cat $FILENAME_TMPCHANGELOG >> CHANGELOG.md
|
|
||||||
fi
|
|
||||||
echo "Please verify and adjust version information that was prepended to CHANGELOG.md file"
|
|
||||||
echo "Diff looks like this:"
|
|
||||||
echo
|
|
||||||
echo '###### Diff start ######'
|
|
||||||
|
|
||||||
## Disable exit on $? -ne 0 for the diff command, since it returns $? == 1 if a diff was found
|
|
||||||
set +e
|
|
||||||
diff -u $FILENAME_TMPCHANGELOG CHANGELOG.md
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo '###### Diff end ######'
|
|
||||||
echo
|
|
||||||
echo "In case this is not correct, press ctrl+z to pause this script, adjust CHANGELOG.md and get back using the fg command"
|
|
||||||
while ! confirm "Continue?"; do
|
|
||||||
echo "And now?"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Commit generated release information"
|
|
||||||
rm -f $FILENAME_TMPCHANGELOG
|
|
||||||
git add VERSION
|
|
||||||
git add CHANGELOG.md
|
|
||||||
git commit -m "${REPOSITORY_NAME} ${RELEASE_VERSION}: ${SHORT_SUMMARY}"
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Checkout and pull master branch"
|
|
||||||
git checkout master
|
|
||||||
git pull $REMOTE master
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Merge release branch to master branch"
|
|
||||||
git merge --no-ff --log --no-edit ${RELEASE_BRANCH}
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Create release tag ${RELEASE_VERSION}"
|
|
||||||
git tag -a ${RELEASE_VERSION} -m "${REPOSITORY_NAME} ${RELEASE_VERSION}: ${SHORT_SUMMARY}"
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Merge release branch to next branch"
|
|
||||||
git checkout next
|
|
||||||
git merge ${RELEASE_BRANCH}
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Delete release branch - it's obsolete now"
|
|
||||||
git branch -d ${RELEASE_BRANCH}
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "Push all changes to remote repository"
|
|
||||||
git push $REMOTE master next ${RELEASE_VERSION}
|
|
||||||
exit 0
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
---
|
|
||||||
# tasks file for ansible-freeipa-client
|
|
||||||
|
|
||||||
- name: Assert supported distribution
|
|
||||||
tags:
|
|
||||||
- assertion
|
|
||||||
- freeipaclient
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ansible_distribution + '-' + ansible_distribution_major_version in freeipaclient_supported_distributions
|
|
||||||
|
|
||||||
- name: Assert required variables
|
|
||||||
tags:
|
|
||||||
- assertion
|
|
||||||
- freeipaclient
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- freeipaclient_server is defined
|
|
||||||
- freeipaclient_domain is defined
|
|
||||||
- freeipaclient_enroll_user is defined
|
|
||||||
- freeipaclient_enroll_pass is defined
|
|
||||||
|
|
||||||
- name: Import variables
|
|
||||||
tags:
|
|
||||||
- import
|
|
||||||
- freeipaclient
|
|
||||||
include_vars: "{{ ansible_distribution }}.yml"
|
|
||||||
|
|
||||||
- name: Set DNS server
|
|
||||||
tags:
|
|
||||||
- dns
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
when: freeipaclient_dns_server is defined
|
|
||||||
lineinfile:
|
|
||||||
state: present
|
|
||||||
line: "nameserver {{ freeipaclient_dns_server }}"
|
|
||||||
dest: /etc/resolv.conf
|
|
||||||
|
|
||||||
- name: Update apt cache
|
|
||||||
tags:
|
|
||||||
- packagemanagement
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
when: ansible_pkg_mgr == 'apt'
|
|
||||||
apt:
|
|
||||||
update_cache: true
|
|
||||||
cache_valid_time: 3600
|
|
||||||
|
|
||||||
- name: Install required packages
|
|
||||||
tags:
|
|
||||||
- packagemanagement
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
with_items: "{{ freeipaclient_packages }}"
|
|
||||||
package:
|
|
||||||
state: present
|
|
||||||
name: "{{ item }}"
|
|
||||||
|
|
||||||
- name: Check if host is enrolled
|
|
||||||
tags:
|
|
||||||
- enroll
|
|
||||||
- freeipaclient
|
|
||||||
register: freeipaclient_ipaconf
|
|
||||||
check_mode: no
|
|
||||||
stat:
|
|
||||||
path: /etc/ipa/default.conf
|
|
||||||
|
|
||||||
- name: Enroll host in domain
|
|
||||||
tags:
|
|
||||||
- enroll
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
when: not freeipaclient_ipaconf.stat.exists
|
|
||||||
command: >
|
|
||||||
{{ freeipaclient_install_command }}
|
|
||||||
{{'--hostname=' + freeipaclient_hostname if freeipaclient_hostname is defined else '--hostname=' + ansible_nodename }}
|
|
||||||
--server={{ freeipaclient_server }}
|
|
||||||
--domain={{ freeipaclient_domain }}
|
|
||||||
--principal={{ freeipaclient_enroll_user }}
|
|
||||||
--password={{ freeipaclient_enroll_pass }}
|
|
||||||
--ssh-trust-dns
|
|
||||||
--mkhomedir
|
|
||||||
{{ '--enable-dns-updates' if freeipaclient_enable_dns_updates else ''}}
|
|
||||||
--unattended
|
|
||||||
{{ '--all-ip-addresses' if freeipaclient_all_ip_addresses else ''}}
|
|
||||||
{{ '--no-ntp' if not freeipaclient_enable_ntp else ''}}
|
|
||||||
{{ '--force-join' if freeipaclient_force_join else ''}}
|
|
||||||
|
|
||||||
- name: Include Ubuntu specific tasks
|
|
||||||
tags:
|
|
||||||
- ubuntu
|
|
||||||
- freeipaclient
|
|
||||||
when: ansible_os_family == 'Debian'
|
|
||||||
include: ubuntu.yml
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
- name: Enable mkhomedir
|
|
||||||
tags:
|
|
||||||
- ubuntu
|
|
||||||
- mkhomedir
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/pam.d/common-session
|
|
||||||
line: 'session required pam_mkhomedir.so skel=/etc/skel umask=0022'
|
|
||||||
|
|
||||||
- name: Enable sssd sudo functionality
|
|
||||||
tags:
|
|
||||||
- ubuntu
|
|
||||||
- sssd
|
|
||||||
- freeipaclient
|
|
||||||
become: true
|
|
||||||
notify:
|
|
||||||
- restart sssd
|
|
||||||
- restart ssh
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/sssd/sssd.conf
|
|
||||||
regexp: '^services.*'
|
|
||||||
line: 'services = nss, pam, ssh, sudo'
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
vars:
|
|
||||||
freeipaclient_force_join: true
|
|
||||||
freeipaclient_server: ipa.demo1.freeipa.org
|
|
||||||
freeipaclient_domain: ipa.demo1.freeipa.org
|
|
||||||
freeipaclient_enroll_user: admin
|
|
||||||
freeipaclient_enroll_pass: Secret123
|
|
||||||
freeipaclient_hostname: ansible-freeipa-client-test.demo1.freeipa.org
|
|
||||||
roles:
|
|
||||||
- ansible-freeipa-client
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
freeipaclient_install_command: '/sbin/ipa-client-install'
|
|
||||||
freeipaclient_packages:
|
|
||||||
- ipa-client
|
|
||||||
- dbus-python
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
freeipaclient_install_command: '/sbin/ipa-client-install'
|
|
||||||
freeipaclient_packages:
|
|
||||||
- freeipa-client
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
freeipaclient_install_command: '/sbin/ipa-client-install'
|
|
||||||
freeipaclient_packages:
|
|
||||||
- ipa-client
|
|
||||||
- dbus-python
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
freeipaclient_install_command: '/usr/sbin/ipa-client-install'
|
|
||||||
freeipaclient_packages:
|
|
||||||
- freeipa-client
|
|
||||||
- dnsutils
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for ansible-freeipa-client
|
|
||||||
freeipaclient_supported_distributions:
|
|
||||||
- Ubuntu-14
|
|
||||||
- Ubuntu-16
|
|
||||||
- Ubuntu-18
|
|
||||||
- CentOS-7
|
|
||||||
- RedHat-7
|
|
||||||
- Fedora-24
|
|
||||||
113
roles/ansible-network.cisco_ios/.gitignore
vendored
113
roles/ansible-network.cisco_ios/.gitignore
vendored
@@ -1,113 +0,0 @@
|
|||||||
# IDE
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
# Ansible
|
|
||||||
*.log
|
|
||||||
*.retry
|
|
||||||
*.swp
|
|
||||||
!*.gitkeep
|
|
||||||
ansible.cfg
|
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
|
||||||
__pycache__/
|
|
||||||
*.py[cod]
|
|
||||||
*$py.class
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Distribution / packaging
|
|
||||||
.Python
|
|
||||||
build/
|
|
||||||
develop-eggs/
|
|
||||||
dist/
|
|
||||||
downloads/
|
|
||||||
eggs/
|
|
||||||
.eggs/
|
|
||||||
lib64/
|
|
||||||
parts/
|
|
||||||
sdist/
|
|
||||||
var/
|
|
||||||
wheels/
|
|
||||||
*.egg-info/
|
|
||||||
.installed.cfg
|
|
||||||
*.egg
|
|
||||||
MANIFEST
|
|
||||||
|
|
||||||
# PyInstaller
|
|
||||||
# Usually these files are written by a python script from a template
|
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
||||||
*.manifest
|
|
||||||
*.spec
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
pip-delete-this-directory.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
htmlcov/
|
|
||||||
.tox/
|
|
||||||
.coverage
|
|
||||||
.coverage.*
|
|
||||||
.cache
|
|
||||||
nosetests.xml
|
|
||||||
coverage.xml
|
|
||||||
*.cover
|
|
||||||
.hypothesis/
|
|
||||||
.pytest_cache/
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
*.pot
|
|
||||||
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
|
|
||||||
# Flask stuff:
|
|
||||||
instance/
|
|
||||||
.webassets-cache
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# PyBuilder
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
|
||||||
.ipynb_checkpoints
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
.python-version
|
|
||||||
|
|
||||||
# celery beat schedule file
|
|
||||||
celerybeat-schedule
|
|
||||||
|
|
||||||
# SageMath parsed files
|
|
||||||
*.sage.py
|
|
||||||
|
|
||||||
# Environments
|
|
||||||
.env
|
|
||||||
.venv
|
|
||||||
env/
|
|
||||||
venv/
|
|
||||||
ENV/
|
|
||||||
env.bak/
|
|
||||||
venv.bak/
|
|
||||||
|
|
||||||
# Spyder project settings
|
|
||||||
.spyderproject
|
|
||||||
.spyproject
|
|
||||||
|
|
||||||
# Rope project settings
|
|
||||||
.ropeproject
|
|
||||||
|
|
||||||
# mkdocs documentation
|
|
||||||
/site
|
|
||||||
|
|
||||||
# mypy
|
|
||||||
.mypy_cache/
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
extends: default
|
|
||||||
|
|
||||||
rules:
|
|
||||||
braces:
|
|
||||||
max-spaces-inside: 1
|
|
||||||
level: error
|
|
||||||
brackets:
|
|
||||||
max-spaces-inside: 1
|
|
||||||
level: error
|
|
||||||
line-length: disable
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
=========================
|
|
||||||
Ansible Network cisco_ios
|
|
||||||
=========================
|
|
||||||
.. _cisco_ios_v2.7.1:
|
|
||||||
|
|
||||||
v2.7.1
|
|
||||||
======
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.7.1_Minor Changes:
|
|
||||||
|
|
||||||
Minor Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- Adds parser for reload reason. `ios-#87 <https://github.com/ansible-network/cisco_ios/pull/87>`_.
|
|
||||||
- Fixed message ``missing required arg: config_manager_text``. `ios-#88 <https://github.com/ansible-network/cisco_ios/pull/88>`_.
|
|
||||||
- Remove set defaults task files. `ios-#89 <https://github.com/ansible-network/cisco_ios/pull/89>`_.
|
|
||||||
- Use default template if no specific peer provider folder is present. `ios-#90 <https://github.com/ansible-network/cisco_ios/pull/90>`_.
|
|
||||||
- Add unconfigure task hooks. `ios-#92 <https://github.com/ansible-network/cisco_ios/pull/92>`_.
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.7.0:
|
|
||||||
|
|
||||||
v2.7.0
|
|
||||||
======
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.7.0_Major Changes:
|
|
||||||
|
|
||||||
Major Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- Initial release of 2.7.0 ``cisco_ios`` Ansible role that is supported with Ansible 2.7.0
|
|
||||||
- Dependant role ``ansible-network.network-engine`` should be upgraded with version >= 2.7.2
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.7.0_Bugfixes:
|
|
||||||
|
|
||||||
Bugfixes
|
|
||||||
--------
|
|
||||||
|
|
||||||
- multiline banner processing (cli_config issue) (#69)
|
|
||||||
- Ensure that subset is a list. Align docs with fact map (#47)
|
|
||||||
- Created test for show_interfaces parser (#58)
|
|
||||||
- fix for 'interfaces' facts (#55)
|
|
||||||
- fix for handling config text with lines containing only whitespace chars (#64)
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.3:
|
|
||||||
|
|
||||||
v2.6.3
|
|
||||||
======
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.3_New Features
|
|
||||||
|
|
||||||
New Features
|
|
||||||
------------
|
|
||||||
|
|
||||||
- NEW provider tasks and parsers for net_operations role
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.3_Bugfixes:
|
|
||||||
|
|
||||||
Bugfixes
|
|
||||||
--------
|
|
||||||
|
|
||||||
- configure_user task should use config_manager_file instead of config_manager_text
|
|
||||||
- uptime facts from cisco IOS has separate keys for year, week, days hours and time
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.2:
|
|
||||||
|
|
||||||
v2.6.2
|
|
||||||
======
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.2_New Features
|
|
||||||
|
|
||||||
New Features
|
|
||||||
------------
|
|
||||||
|
|
||||||
- NEW Added CPF and Fiber Optic DOM parser
|
|
||||||
- NEW Added dependency role plugin check
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.1:
|
|
||||||
|
|
||||||
v2.6.1
|
|
||||||
======
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.1_New Action Plugins:
|
|
||||||
|
|
||||||
New Action Plugins
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- NEW ``ios_user_manager`` action plugin
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.1_New Tasks:
|
|
||||||
|
|
||||||
New Tasks
|
|
||||||
---------
|
|
||||||
|
|
||||||
- NEW ``configure_user`` task
|
|
||||||
|
|
||||||
.. _cisco_ios_v2.6.1_Bugfixes:
|
|
||||||
|
|
||||||
Bugfixes
|
|
||||||
--------
|
|
||||||
|
|
||||||
- Refactor vrf and bgp output and improve reliability (#29)
|
|
||||||
- better support for working with config_manager tasks
|
|
||||||
|
|
||||||
devel
|
|
||||||
=====
|
|
||||||
|
|
||||||
New Functions
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- NEW `get_facts` retrive and parse facts from cisco ios devices
|
|
||||||
- NEW `config_manager/get` support for config_manager get function
|
|
||||||
- NEW `config_manager/load` support for config_manager load function
|
|
||||||
- NEW `config_manager/save` support for config_manager save function
|
|
||||||
- NEW `configure_user` support for configuring users on cisco ios devices
|
|
||||||
|
|
||||||
|
|
||||||
Major Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- Initial release of the `cisco_ios` role.
|
|
||||||
@@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
{one line to give the program's name and a brief idea of what it does.}
|
|
||||||
Copyright (C) {year} {name of author}
|
|
||||||
|
|
||||||
This program 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.
|
|
||||||
|
|
||||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
{project} Copyright (C) {year} {fullname}
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# cisco_ios
|
|
||||||
|
|
||||||
This Ansible Network role provides a set of platform dependent fuctions that
|
|
||||||
are designed to work with Cisco IOS network devices. The functions included
|
|
||||||
int his role inlcuding both configuration and fact collection.
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
* Ansible 2.6 or later
|
|
||||||
* Ansible Network Engine Role 2.6.0 or later
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
This section provides a list of the availabe functions that are including
|
|
||||||
in this role. Any of the provided functions can be implemented in Ansible
|
|
||||||
playbooks to perform automation activities on Cisco IOS devices.
|
|
||||||
|
|
||||||
Please see the documentation link for each function for details on how to use
|
|
||||||
the function in an Ansible playbook.
|
|
||||||
|
|
||||||
* get_facts [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/get_facts.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/get_facts.md)
|
|
||||||
|
|
||||||
### Config Manager
|
|
||||||
* config_manager/get [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/config_manager/get.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/config_manager/get.md)
|
|
||||||
* config_manager/load [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/config_manager/load.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/config_manager/load.md)
|
|
||||||
|
|
||||||
### Cloud VPN
|
|
||||||
* cloud_vpn/configure_vpn_initiator [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/cloud_vpn/configure_vpn_initiator.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/cloud_vpn/configure_vpn_initiator.md)
|
|
||||||
* cloud_vpn/configure_routing_initiator [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/cloud_vpn/configure_routing_initiator.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/cloud_vpn/configure_routing_initiator.md)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
GPLv3
|
|
||||||
|
|
||||||
## Author Information
|
|
||||||
|
|
||||||
Ansible Network Community
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
# (c) 2018, Ansible by Red Hat, inc
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'network'}
|
|
||||||
|
|
||||||
DOCUMENTATION = """
|
|
||||||
---
|
|
||||||
module: extract_banners
|
|
||||||
author: Ansible Network Team
|
|
||||||
short_description: remove banners from config text
|
|
||||||
description:
|
|
||||||
- The config text specified in C(config) will be used to extract banners
|
|
||||||
from it. Banners need to be executed on device in special manner. It
|
|
||||||
returns configs with banner removed and a dictionary of banners
|
|
||||||
version_added: "2.7"
|
|
||||||
options:
|
|
||||||
config:
|
|
||||||
description:
|
|
||||||
- Config text from which banners need to be extracted.
|
|
||||||
required: yes
|
|
||||||
default: null
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = """
|
|
||||||
- name: extract multiline banners
|
|
||||||
extract_banners:
|
|
||||||
config: "{{ ios_config_text }}"
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = """
|
|
||||||
config:
|
|
||||||
description: returns the config with masked banners
|
|
||||||
returned: always
|
|
||||||
type: str
|
|
||||||
banners:
|
|
||||||
description: returns the extracted banners
|
|
||||||
returned: always
|
|
||||||
type: dict
|
|
||||||
"""
|
|
||||||
import re
|
|
||||||
from ansible.plugins.action import ActionBase
|
|
||||||
from ansible.module_utils._text import to_text
|
|
||||||
from ansible.errors import AnsibleError
|
|
||||||
|
|
||||||
try:
|
|
||||||
from __main__ import display
|
|
||||||
except ImportError:
|
|
||||||
from ansible.utils.display import Display
|
|
||||||
display = Display()
|
|
||||||
|
|
||||||
|
|
||||||
class ActionModule(ActionBase):
|
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=None):
|
|
||||||
''' handler for extract_banners '''
|
|
||||||
|
|
||||||
if task_vars is None:
|
|
||||||
task_vars = dict()
|
|
||||||
|
|
||||||
result = super(ActionModule, self).run(tmp, task_vars)
|
|
||||||
del tmp # tmp no longer has any effect
|
|
||||||
|
|
||||||
try:
|
|
||||||
config = self._task.args['config']
|
|
||||||
except KeyError as exc:
|
|
||||||
raise AnsibleError(to_text(exc))
|
|
||||||
|
|
||||||
# make config required argument
|
|
||||||
if not config:
|
|
||||||
raise AnsibleError('missing required argument `config`')
|
|
||||||
|
|
||||||
banners, masked_config = self._extract_banners(config)
|
|
||||||
result['config'] = masked_config
|
|
||||||
result['banners'] = banners
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _extract_banners(self, config):
|
|
||||||
config_lines = config.split('\n')
|
|
||||||
found_banner_start = 0
|
|
||||||
banner_meta = []
|
|
||||||
for linenum, line in enumerate(config_lines):
|
|
||||||
if not found_banner_start:
|
|
||||||
banner_start = re.search(r'^banner\s+(\w+)\s+(.*)', line)
|
|
||||||
if banner_start:
|
|
||||||
banner_cmd = banner_start.group(1)
|
|
||||||
try:
|
|
||||||
banner_delimiter = banner_start.group(2)
|
|
||||||
banner_delimiter = banner_delimiter.strip()
|
|
||||||
banner_delimiter_esc = re.escape(banner_delimiter)
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
banner_start_index = linenum
|
|
||||||
found_banner_start = 1
|
|
||||||
continue
|
|
||||||
|
|
||||||
if found_banner_start:
|
|
||||||
# Search for delimiter found in current banner start
|
|
||||||
regex = r'%s' % banner_delimiter_esc
|
|
||||||
banner_end = re.search(regex, line)
|
|
||||||
if banner_end:
|
|
||||||
found_banner_start = 0
|
|
||||||
kwargs = {
|
|
||||||
'banner_cmd': banner_cmd,
|
|
||||||
'banner_delimiter': banner_delimiter,
|
|
||||||
'banner_start_index': banner_start_index,
|
|
||||||
'banner_end_index': linenum,
|
|
||||||
}
|
|
||||||
banner_meta.append(kwargs)
|
|
||||||
|
|
||||||
# Build banners from extracted data
|
|
||||||
banner_lines = []
|
|
||||||
for banner in banner_meta:
|
|
||||||
banner_lines.append('banner %s %s' % (banner['banner_cmd'],
|
|
||||||
banner['banner_delimiter']))
|
|
||||||
banner_conf_lines = config_lines[banner['banner_start_index'] + 1: banner['banner_end_index']]
|
|
||||||
for index, conf_line in enumerate(banner_conf_lines):
|
|
||||||
banner_lines.append(conf_line)
|
|
||||||
banner_lines.append('%s' % banner['banner_delimiter'])
|
|
||||||
|
|
||||||
# Delete banner lines from config
|
|
||||||
for banner in banner_meta:
|
|
||||||
banner_lines_range = range(banner['banner_start_index'],
|
|
||||||
banner['banner_end_index'] + 1)
|
|
||||||
for index in banner_lines_range:
|
|
||||||
config_lines[index] = '! banner removed'
|
|
||||||
|
|
||||||
configs = '\n'.join(config_lines)
|
|
||||||
return (banner_lines, configs)
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
# (c) 2018, Ansible by Red Hat, inc
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'network'}
|
|
||||||
import re
|
|
||||||
import base64
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
from ansible.plugins.action import ActionBase
|
|
||||||
|
|
||||||
|
|
||||||
class UserManager:
|
|
||||||
|
|
||||||
def __init__(self, new_users, user_config_data):
|
|
||||||
self.__new_users = new_users
|
|
||||||
self.__user_config_data = user_config_data
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def calculate_fingerprint(sshkey):
|
|
||||||
if ' ' in sshkey:
|
|
||||||
keyparts = sshkey.split(' ')
|
|
||||||
keyparts[1] = hashlib.md5(base64.b64decode(keyparts[1])).hexdigest().upper()
|
|
||||||
return ' '.join(keyparts)
|
|
||||||
|
|
||||||
else:
|
|
||||||
return 'ssh-rsa %s' % hashlib.md5(base64.b64decode(sshkey)).hexdigest().upper()
|
|
||||||
|
|
||||||
def _parse_view(self, data):
|
|
||||||
match = re.search(r'view (\S+)', data, re.M)
|
|
||||||
if match:
|
|
||||||
return match.group(1)
|
|
||||||
|
|
||||||
def _parse_sshkey(self, data):
|
|
||||||
match = re.search(r'key-hash (\S+ \S+(?: .+)?)$', data, re.M)
|
|
||||||
if match:
|
|
||||||
return match.group(1)
|
|
||||||
|
|
||||||
def _parse_privilege(self, data):
|
|
||||||
match = re.search(r'privilege (\S+)', data, re.M)
|
|
||||||
if match:
|
|
||||||
return int(match.group(1))
|
|
||||||
|
|
||||||
def generate_existing_users(self):
|
|
||||||
match = re.findall(r'(?:^(?:u|\s{2}u))sername (\S+)', self.__user_config_data, re.M)
|
|
||||||
if not match:
|
|
||||||
return []
|
|
||||||
|
|
||||||
existing_users = []
|
|
||||||
|
|
||||||
for user in set(match):
|
|
||||||
regex = r'username %s .+$' % user
|
|
||||||
cfg = re.findall(regex, self.__user_config_data, re.M)
|
|
||||||
cfg = '\n'.join(cfg)
|
|
||||||
sshregex = r'username %s\n\s+key-hash .+$' % user
|
|
||||||
sshcfg = re.findall(sshregex, self.__user_config_data, re.M)
|
|
||||||
sshcfg = '\n'.join(sshcfg)
|
|
||||||
|
|
||||||
obj = {
|
|
||||||
'name': user,
|
|
||||||
'sshkey': self._parse_sshkey(sshcfg),
|
|
||||||
'privilege': self._parse_privilege(cfg),
|
|
||||||
'view': self._parse_view(cfg)
|
|
||||||
}
|
|
||||||
|
|
||||||
filtered = {k: v for k, v in obj.items() if v is not None}
|
|
||||||
obj.clear()
|
|
||||||
obj.update(filtered)
|
|
||||||
|
|
||||||
existing_users.append(obj)
|
|
||||||
|
|
||||||
return existing_users
|
|
||||||
|
|
||||||
def filter_users(self):
|
|
||||||
want = self.__new_users
|
|
||||||
for user in want:
|
|
||||||
if 'sshkey' in user:
|
|
||||||
user['sshkey'] = self.calculate_fingerprint(user['sshkey'])
|
|
||||||
|
|
||||||
have = self.generate_existing_users()
|
|
||||||
filtered_users = [x for x in want if x not in have]
|
|
||||||
|
|
||||||
changed = True if len(filtered_users) > 0 else False
|
|
||||||
|
|
||||||
return changed, filtered_users
|
|
||||||
|
|
||||||
|
|
||||||
class ActionModule(ActionBase):
|
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=None):
|
|
||||||
if task_vars is None:
|
|
||||||
task_vars = dict()
|
|
||||||
|
|
||||||
result = super(ActionModule, self).run(tmp, task_vars)
|
|
||||||
|
|
||||||
try:
|
|
||||||
new_users = self._task.args['new_users']
|
|
||||||
user_config_data = self._task.args['user_config']
|
|
||||||
except KeyError as exc:
|
|
||||||
return {'failed': True, 'msg': 'missing required argument: %s' % exc}
|
|
||||||
|
|
||||||
result['changed'], result['stdout'] = UserManager(new_users, user_config_data).filter_users()
|
|
||||||
|
|
||||||
return result
|
|
||||||
@@ -1,262 +0,0 @@
|
|||||||
# (c) 2018, Ansible Inc,
|
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
import copy
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import re
|
|
||||||
import hashlib
|
|
||||||
import netaddr
|
|
||||||
import json
|
|
||||||
import socket
|
|
||||||
|
|
||||||
from ansible.module_utils._text import to_bytes, to_text
|
|
||||||
from ansible.module_utils.connection import Connection
|
|
||||||
from ansible.errors import AnsibleError
|
|
||||||
from ansible.plugins.action import ActionBase
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
|
||||||
from ansible.utils.path import unfrackpath
|
|
||||||
|
|
||||||
try:
|
|
||||||
from __main__ import display
|
|
||||||
except ImportError:
|
|
||||||
from ansible.utils.display import Display
|
|
||||||
display = Display()
|
|
||||||
|
|
||||||
|
|
||||||
class ActionModule(ActionBase):
|
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=None):
|
|
||||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
|
||||||
|
|
||||||
try:
|
|
||||||
show_acl_output_buffer = self._task.args.get('show_acl_output_buffer')
|
|
||||||
except KeyError as exc:
|
|
||||||
return {'failed': True, 'msg': 'missing required argument: %s' % exc}
|
|
||||||
|
|
||||||
try:
|
|
||||||
parser = self._task.args.get('parser')
|
|
||||||
except KeyError as exc:
|
|
||||||
return {'failed': True, 'msg': 'missing required argument: %s' % exc}
|
|
||||||
|
|
||||||
try:
|
|
||||||
generated_flow_file = self._task.args.get('generated_flow_file')
|
|
||||||
except KeyError as exc:
|
|
||||||
return {'failed': True, 'msg': 'missing required argument: %s' % exc}
|
|
||||||
|
|
||||||
generated_flow_file = unfrackpath(generated_flow_file)
|
|
||||||
dest = generated_flow_file
|
|
||||||
|
|
||||||
parser = unfrackpath(parser)
|
|
||||||
if not os.path.exists(parser):
|
|
||||||
return {'failed': True, 'msg': 'path: %s does not exist.' % parser}
|
|
||||||
parser_file = parser
|
|
||||||
|
|
||||||
pd_json = self._parse_acl_with_textfsm(
|
|
||||||
parser_file, show_acl_output_buffer)
|
|
||||||
try:
|
|
||||||
changed = self._write_packet_dict(dest, pd_json)
|
|
||||||
except IOError as exc:
|
|
||||||
result['failed'] = True
|
|
||||||
result['msg'] = ('Exception received : %s' % exc)
|
|
||||||
|
|
||||||
result['changed'] = changed
|
|
||||||
if changed:
|
|
||||||
result['destination'] = dest
|
|
||||||
else:
|
|
||||||
result['dest_unchanged'] = dest
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _create_packet_dict(self, cmd_out):
|
|
||||||
import warnings
|
|
||||||
with warnings.catch_warnings(record=True):
|
|
||||||
warnings.simplefilter("always")
|
|
||||||
from trigger.acl import parse
|
|
||||||
import netaddr
|
|
||||||
import json
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
# pd is list of dictionary of packets
|
|
||||||
pd = []
|
|
||||||
lines = cmd_out.split('\n')
|
|
||||||
for index, line in enumerate(lines):
|
|
||||||
line = to_bytes(line, errors='surrogate_or_strict')
|
|
||||||
pd_it = {}
|
|
||||||
try:
|
|
||||||
p = parse(line)
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if p.terms:
|
|
||||||
match = p.terms[0].match
|
|
||||||
for key in match:
|
|
||||||
if key == 'source-address':
|
|
||||||
for m in match["source-address"]:
|
|
||||||
v = netaddr.IPNetwork(str(m))
|
|
||||||
# Return the host in middle of subnet
|
|
||||||
size_subnet = v.size
|
|
||||||
host_index = int(size_subnet / 2)
|
|
||||||
pd_it["src"] = str(v[host_index])
|
|
||||||
if key == 'destination-address':
|
|
||||||
for m in match["destination-address"]:
|
|
||||||
v = netaddr.IPNetwork(str(m))
|
|
||||||
# Return the host in middle of subnet
|
|
||||||
size_subnet = v.size
|
|
||||||
host_index = int(size_subnet / 2)
|
|
||||||
pd_it["dst"] = str(v[host_index])
|
|
||||||
if key == 'protocol':
|
|
||||||
for m in match['protocol']:
|
|
||||||
pd_it["proto"] = str(m)
|
|
||||||
if key == 'destination-port':
|
|
||||||
for m in match["destination-port"]:
|
|
||||||
pd_it['dst_port'] = str(m)
|
|
||||||
if key == 'source-port':
|
|
||||||
for m in match["source-port"]:
|
|
||||||
pd_it['src_port'] = str(m)
|
|
||||||
|
|
||||||
action = p.terms[0].action
|
|
||||||
for act in action:
|
|
||||||
pd_it["action"] = act
|
|
||||||
|
|
||||||
if pd_it is not None:
|
|
||||||
if "dst" not in pd_it:
|
|
||||||
pd_it["dst"] = "any"
|
|
||||||
if "src" not in pd_it:
|
|
||||||
pd_it["src"] = "any"
|
|
||||||
pd_it["service_line_index"] = str(index)
|
|
||||||
pd.append(pd_it)
|
|
||||||
|
|
||||||
return json.dumps(pd, indent=4)
|
|
||||||
|
|
||||||
def _write_packet_dict(self, dest, contents):
|
|
||||||
# Check for Idempotency
|
|
||||||
if os.path.exists(dest):
|
|
||||||
try:
|
|
||||||
with open(dest, 'r') as f:
|
|
||||||
old_content = f.read()
|
|
||||||
except IOError as ioexc:
|
|
||||||
raise IOError(ioexc)
|
|
||||||
sha1 = hashlib.sha1()
|
|
||||||
old_content_b = to_bytes(old_content, errors='surrogate_or_strict')
|
|
||||||
sha1.update(old_content_b)
|
|
||||||
checksum_old = sha1.digest()
|
|
||||||
|
|
||||||
sha1 = hashlib.sha1()
|
|
||||||
new_content_b = to_bytes(contents, errors='surrogate_or_strict')
|
|
||||||
sha1.update(new_content_b)
|
|
||||||
checksum_new = sha1.digest()
|
|
||||||
if checksum_old == checksum_new:
|
|
||||||
return (False)
|
|
||||||
|
|
||||||
try:
|
|
||||||
with open(dest, 'w') as f:
|
|
||||||
f.write(contents)
|
|
||||||
except IOError as ioexc:
|
|
||||||
raise IOError(ioexc)
|
|
||||||
|
|
||||||
return (True)
|
|
||||||
|
|
||||||
def _parse_acl_with_textfsm(self, parser_file, output):
|
|
||||||
import textfsm
|
|
||||||
tmp = open(parser_file)
|
|
||||||
re_table = textfsm.TextFSM(tmp)
|
|
||||||
results = re_table.ParseText(output)
|
|
||||||
fsm_results = []
|
|
||||||
for item in results:
|
|
||||||
facts = {}
|
|
||||||
facts.update(dict(zip(re_table.header, item)))
|
|
||||||
fsm_results.append(facts)
|
|
||||||
|
|
||||||
pd = []
|
|
||||||
parsed_acl = []
|
|
||||||
# Convert dictionary of terms into flows dictionary
|
|
||||||
for term in fsm_results:
|
|
||||||
pd_it = {}
|
|
||||||
original_terms = {}
|
|
||||||
for k, v in term.items():
|
|
||||||
if k == 'LINE_NUM' and v == '':
|
|
||||||
# Empty line with just name
|
|
||||||
continue
|
|
||||||
elif k == 'LINE_NUM' and v != '':
|
|
||||||
pd_it["service_line_index"] = v
|
|
||||||
original_terms["service_line_index"] = v
|
|
||||||
if k == 'PROTOCOL' and v != '':
|
|
||||||
pd_it["proto"] = v
|
|
||||||
original_terms['proto'] = v
|
|
||||||
if k == 'ACTION' and v != '':
|
|
||||||
pd_it["action"] = v
|
|
||||||
original_terms['action'] = v
|
|
||||||
if k == 'SRC_NETWORK' and v != '':
|
|
||||||
if 'SRC_WILDCARD' in term:
|
|
||||||
src_mask = term['SRC_WILDCARD']
|
|
||||||
src_invert_mask = sum([bin(255 - int(x)).count("1") for x in
|
|
||||||
src_mask.split(".")])
|
|
||||||
else:
|
|
||||||
src_invert_mask = '32'
|
|
||||||
cidr = "%s/%s" % (v, src_invert_mask)
|
|
||||||
src_ip = netaddr.IPNetwork(cidr)
|
|
||||||
size_subnet = src_ip.size
|
|
||||||
host_index = int(size_subnet / 2)
|
|
||||||
pd_it['src'] = str(src_ip[host_index])
|
|
||||||
original_terms['src'] = src_ip
|
|
||||||
if k == 'SRC_ANY' and v != '':
|
|
||||||
pd_it['src'] = "any"
|
|
||||||
original_terms['src'] = netaddr.IPNetwork('0.0.0.0/0')
|
|
||||||
if k == 'SRC_HOST' and v != '':
|
|
||||||
pd_it['src'] = v
|
|
||||||
original_terms['src'] = v
|
|
||||||
if k == 'SRC_PORT' and v != '':
|
|
||||||
if not v[0].isdigit():
|
|
||||||
v = str(socket.getservbyname(v))
|
|
||||||
pd_it['src_port'] = v
|
|
||||||
original_terms['src_port'] = v
|
|
||||||
if k == 'DST_NETWORK' and v != '':
|
|
||||||
if 'DST_WILDCARD' in term:
|
|
||||||
dst_mask = term['DST_WILDCARD']
|
|
||||||
dst_invert_mask = sum([bin(255 - int(x)).count("1") for x in
|
|
||||||
dst_mask.split(".")])
|
|
||||||
else:
|
|
||||||
dst_invert_mask = '32'
|
|
||||||
d_cidr = "%s/%s" % (v, dst_invert_mask)
|
|
||||||
dst_ip = netaddr.IPNetwork(d_cidr)
|
|
||||||
d_size_subnet = dst_ip.size
|
|
||||||
d_host_index = int(d_size_subnet / 2)
|
|
||||||
pd_it['dst'] = str(dst_ip[d_host_index])
|
|
||||||
original_terms['dst'] = dst_ip
|
|
||||||
if k == 'DST_ANY' and v != '':
|
|
||||||
pd_it['dst'] = "any"
|
|
||||||
original_terms['dst'] = netaddr.IPNetwork('0.0.0.0/0')
|
|
||||||
if k == 'DST_HOST' and v != '':
|
|
||||||
pd_it['dst'] = v
|
|
||||||
original_terms['dst'] = v
|
|
||||||
if k == 'DST_PORT' and v != '':
|
|
||||||
if not v[0].isdigit():
|
|
||||||
v = str(socket.getservbyname(v))
|
|
||||||
pd_it['dst_port'] = v
|
|
||||||
original_terms['dst_port'] = v
|
|
||||||
|
|
||||||
if pd_it:
|
|
||||||
pd.append(pd_it)
|
|
||||||
if original_terms:
|
|
||||||
parsed_acl.append(original_terms)
|
|
||||||
|
|
||||||
# Store parsed acl on this object for later processing
|
|
||||||
self._parsed_acl = parsed_acl
|
|
||||||
return json.dumps(pd, indent=4)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# This is a cross-platform list tracking distribution packages needed by tests;
|
|
||||||
# see http://docs.openstack.org/infra/bindep/ for additional information.
|
|
||||||
|
|
||||||
gcc-c++ [test platform:rpm]
|
|
||||||
python3-devel [test platform:rpm]
|
|
||||||
python3 [test platform:rpm]
|
|
||||||
python36 [test !platform:fedora-28]
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
cloud_vpn_initiator_user: ec2-user
|
|
||||||
cloud_vpn_initiator_ansible_connection: network_cli
|
|
||||||
cloud_vpn_initiator_outside_interface: GigabitEthernet1
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for ansible-network.cisco_ios
|
|
||||||
#
|
|
||||||
ios_config_rollback_enabled: true
|
|
||||||
ios_config_use_terminal: true
|
|
||||||
ios_config_remove_temp_files: "{{ remove_temp_files | default(True) }}"
|
|
||||||
ios_config_replace: "{{ config_manager_replace | default(False) }}"
|
|
||||||
|
|
||||||
ios_config_source:
|
|
||||||
running: show running-config
|
|
||||||
startup: show startup-config
|
|
||||||
|
|
||||||
ios_get_facts_command_map: "{{ role_path }}/vars/get_facts_command_map.yaml"
|
|
||||||
ios_get_facts_subset: "{{ subset | default(['default']) }}"
|
|
||||||
ios_dependent_role_check: true
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
# Configure VPN routing as initiator
|
|
||||||
The `cloud_vpn/configure_routing_initiator` function will configure the routing where
|
|
||||||
a VPN as initiator has been configured previously on Cisco IOS devices.
|
|
||||||
It is performed by calling the `cloud_vpn/configure_routing_initiator` task from the role.
|
|
||||||
The task will process variables needed for routing configuration and apply it to the device.
|
|
||||||
|
|
||||||
Below is an example to configure routing on a CSR device configured as initiator,
|
|
||||||
where the responder is AWS VPN.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Configure initiator routing
|
|
||||||
include_role:
|
|
||||||
name: ansible-network.cisco_ios
|
|
||||||
tasks_from: cloud_vpn/configure_routing_initiator
|
|
||||||
vars:
|
|
||||||
cloud_vpn_responder_provider: aws_vpn
|
|
||||||
cloud_vpn_responder_cidr: 192.168.0.0/24
|
|
||||||
```
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
None
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# Configure VPN as initiator
|
|
||||||
The `cloud_vpn/configure_vpn_initiator` function will configure IPSEC VPN as initiator
|
|
||||||
on Cisco IOS devices.
|
|
||||||
It is performed by calling the `cloud_vpn/configure_vpn_initiator` task from the role.
|
|
||||||
The task will process variables needed for VPN configuration and apply it to the device.
|
|
||||||
|
|
||||||
Below is an example to configure an IPSEC VPN as initiator on CSR device, where
|
|
||||||
the responder is AWS VPN:
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Configure IPSEC VPN as initiator
|
|
||||||
include_role:
|
|
||||||
name: ansible-network.cisco_ios
|
|
||||||
tasks_from: cloud_vpn/configure_vpn_initiator
|
|
||||||
vars:
|
|
||||||
cloud_vpn_name: myvpn
|
|
||||||
cloud_vpn_psk: mypsksecret
|
|
||||||
cloud_vpn_initiator_provider: csr
|
|
||||||
cloud_vpn_initiator_outside_interface: GigabitEthernet1
|
|
||||||
cloud_vpn_initiator_tunnel_ip: 169.254.56.25
|
|
||||||
cloud_vpn_initiator_tunnel_failover_ip: 169.254.56.29
|
|
||||||
cloud_vpn_responder_provider: aws_vpn
|
|
||||||
cloud_vpn_responder_public_ip: 18.191.132.220
|
|
||||||
cloud_vpn_responder_failover_ip: 18.191.132.221
|
|
||||||
cloud_vpn_responder_tunnel_ip: 169.254.56.26
|
|
||||||
cloud_vpn_responder_tunnel_failover_ip: 169.254.56.30
|
|
||||||
```
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
None
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
# Get configuration from device
|
|
||||||
The `config_manager/get` function will return the either the current active or current
|
|
||||||
saved configuration from an Cisco IOS devices. This function is only
|
|
||||||
supported over `network_cli` connections.
|
|
||||||
|
|
||||||
The `config_manager/get` function will also parse the device active configuration into
|
|
||||||
a set of host facts during its execution. All of the parsed facts are stored
|
|
||||||
in the ``cisco_ios.config`` top level facts key.
|
|
||||||
|
|
||||||
## How to get the device configuration
|
|
||||||
Retrieving the configuration from the device involves just calling the
|
|
||||||
`config_manager/get` function from the role. By default, the `config_manager/get` role will
|
|
||||||
return the device active (running) configuraiton. The text configuration will
|
|
||||||
be returned as a fact for the host. The configuration text is stored in the
|
|
||||||
`configuration` fact.
|
|
||||||
|
|
||||||
Below is an example of calling the `config_manager/get` function from the playbook.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- name ansible-network.cisco_ios
|
|
||||||
function: config_manager/get
|
|
||||||
```
|
|
||||||
|
|
||||||
The above playbook will return the current running config from each host listed
|
|
||||||
in the `cisco_ios` group in inventory.
|
|
||||||
|
|
||||||
### Get the current startup config
|
|
||||||
By default the `config_manager/get` function will return the device running
|
|
||||||
configuration. If you want to retrieve the device startup configuration, set
|
|
||||||
the value of `source` to `startup`.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- name ansible-network.cisco_ios
|
|
||||||
function: config_manager/get
|
|
||||||
source: startup
|
|
||||||
```
|
|
||||||
|
|
||||||
### Implement using tasks
|
|
||||||
The `config_manager/get` function can also be implemented in the `tasks` during the
|
|
||||||
playbook run using either the `include_role` or `import_role` modules as shown
|
|
||||||
below.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: collect facts from cisco ios devices
|
|
||||||
include_role:
|
|
||||||
name: ansible-network.cisco_ios
|
|
||||||
tasks_from: config_manager/get
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to add additional parsers
|
|
||||||
|
|
||||||
The configuration facts are returned by this function are parsed using the
|
|
||||||
parsers in the `parser_templates/config` folder. To add a new parser, simply
|
|
||||||
create a PR and add the new parser to the folder. Once merged, the
|
|
||||||
`config_manager/get` function will automatically use the new parser.
|
|
||||||
|
|
||||||
## Arguments
|
|
||||||
|
|
||||||
### source
|
|
||||||
|
|
||||||
Defines the configuration source to return from the device. This argument
|
|
||||||
accepts one of `running` or `startup`. When the value is set to `running`
|
|
||||||
(default), the current active configuration is returned. When the value is set
|
|
||||||
to `sartup`, the device saved configuration is returned.
|
|
||||||
|
|
||||||
The default value is `running`
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
None
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
# Load configuration onto device
|
|
||||||
The `config_manager/load` function will take a Cisco IOS configuration file and load it
|
|
||||||
onto the device. This function supports either merging the configuration with
|
|
||||||
the current active configuration or replacing the current active configuration
|
|
||||||
with the provided configuration file.
|
|
||||||
|
|
||||||
The `config_manager/load` function will return the full configuration diff in the
|
|
||||||
`ios_diff` fact.
|
|
||||||
|
|
||||||
NOTE: When performing a configuration replace function be sure to specify the
|
|
||||||
entire configuration to be loaded otherwise you could end up not being able to
|
|
||||||
reconnect to your IOS device after the configuration has been loaded.
|
|
||||||
|
|
||||||
## How to load and merge a configuration
|
|
||||||
Loading and merging a configuration file is the default operation for the
|
|
||||||
`config_manager/load` function. It will take the contents of a Cisco IOS configuration
|
|
||||||
file and merge it with the current device active configurations.
|
|
||||||
|
|
||||||
Below is an example of calling the `config_manager/load` function from the playbook.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- name ansible_network.cisco_ios
|
|
||||||
function: config_manager/load
|
|
||||||
config_manager_text: "{{ lookup('file', 'ios.cfg') }}"
|
|
||||||
```
|
|
||||||
|
|
||||||
The above playbook will load the specified configuration file onto each device
|
|
||||||
in the `cisco_ios` host group.
|
|
||||||
|
|
||||||
## How to replace the current active configuration
|
|
||||||
The `config_manager/load` function also supports replacing the current active
|
|
||||||
configuration with the configuration file located on the Ansible controller.
|
|
||||||
In order to replace the device's active configuration, set the value of the
|
|
||||||
`config_manager_replace` setting to `True`.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- name ansible_network.cisco_ios
|
|
||||||
function: config_manager/load
|
|
||||||
config_manager_text: "{{ lookup('file', 'ios.cfg') }}"
|
|
||||||
config_manager_replace: true
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Arguments
|
|
||||||
|
|
||||||
### config_manager_text
|
|
||||||
|
|
||||||
This value accepts the text form of the configuration to be loaded on to the remote device.
|
|
||||||
The configuration file should be the native set of commands used to configure the remote device.
|
|
||||||
|
|
||||||
The default value is `null`
|
|
||||||
|
|
||||||
### config_manager_replace
|
|
||||||
|
|
||||||
Specifies whether or not the source configuration should replace the current
|
|
||||||
active configuration on the target IOS device. When this value is set to
|
|
||||||
False, the source configuration is merged with the active configuration. When
|
|
||||||
this value is set to True, the source configuration will replace the current
|
|
||||||
active configuration
|
|
||||||
|
|
||||||
The default value is `False`
|
|
||||||
|
|
||||||
### ios_config_remove_temp_files
|
|
||||||
|
|
||||||
Configures the function to remove or not remove the temp files created when
|
|
||||||
preparing to load the configuration file. There are two locations for temp
|
|
||||||
files, one on the Ansible controller and one on the device. This argument
|
|
||||||
accepts a boolean value.
|
|
||||||
|
|
||||||
The default value is `True`
|
|
||||||
|
|
||||||
### ios_config_rollback_enabled
|
|
||||||
|
|
||||||
Configures whether or not automatic rollback is enabled during the execution of
|
|
||||||
the function. When enabled, if an error is enountered, then the configuration
|
|
||||||
is automatically returned to the original running-config. If disabled, then
|
|
||||||
the rollback operation is not performed automatically.
|
|
||||||
|
|
||||||
The default value is `True`
|
|
||||||
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
# Get facts from device
|
|
||||||
|
|
||||||
The `get_facts` function can be used to collect facts from an Cisco IOS
|
|
||||||
devices. This function is only supported over `network_cli` connection
|
|
||||||
type and requires the `ansible_network_os` value set to `ios`.
|
|
||||||
|
|
||||||
## How to get facts from the device
|
|
||||||
|
|
||||||
To collect facts from the device, simply include this function in the playbook
|
|
||||||
using either the `roles` directive or the `tasks` directive. If no other
|
|
||||||
options are provided, then all of the available facts will be collected for the
|
|
||||||
device.
|
|
||||||
|
|
||||||
Below is an example of how to use the `roles` directive to collect all facts
|
|
||||||
from the IOS device.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- name ansible-network.cisco_ios
|
|
||||||
function: get_facts
|
|
||||||
```
|
|
||||||
|
|
||||||
The above playbook will return the facts for the host under the `cisco_ios`
|
|
||||||
top level key.
|
|
||||||
|
|
||||||
### Filter the subset of facts returned
|
|
||||||
|
|
||||||
By default all available facts will be returned by the `get_facts` function.
|
|
||||||
If you only want to return a subset of the facts, you can specify the `subset`
|
|
||||||
variable as a list of keys to return.
|
|
||||||
|
|
||||||
For instance, the below will return only `interfaces` and `system` facts.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- name ansible-network.cisco_ios
|
|
||||||
function: get_facts
|
|
||||||
subset:
|
|
||||||
- system
|
|
||||||
```
|
|
||||||
|
|
||||||
### Implement using tasks
|
|
||||||
|
|
||||||
The `get_facts` function can also be implemented using the `tasks` directive
|
|
||||||
instead of the `roles` directive. By using the `tasks` directive, you can
|
|
||||||
control when the fact collection is run.
|
|
||||||
|
|
||||||
Below is an example of how to use the `get_facts` function with `tasks`.
|
|
||||||
|
|
||||||
```
|
|
||||||
- hosts: cisco_ios
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: collect facts from cisco ios devices
|
|
||||||
import_role:
|
|
||||||
name: ansible-network.cisco_ios
|
|
||||||
tasks_from: get_facts
|
|
||||||
vars:
|
|
||||||
subset:
|
|
||||||
- system
|
|
||||||
- interfaces
|
|
||||||
```
|
|
||||||
|
|
||||||
## Adding new parsers
|
|
||||||
|
|
||||||
Over time new parsers can be added (or updated) to the role to add additional
|
|
||||||
or enhanced functionality. To add or update parsers perform the following
|
|
||||||
steps:
|
|
||||||
|
|
||||||
* Add (or update) command parser located ino `parse_templates/cli`
|
|
||||||
|
|
||||||
* Update the `vars/get_facts_command_map.yaml` file to map the CLI command
|
|
||||||
to the parser
|
|
||||||
|
|
||||||
The `get_facts_command_map.yaml` file provides a mapping between CLI command
|
|
||||||
and parser used to transform the output into Ansible facts.
|
|
||||||
|
|
||||||
### Understanding the mapping file
|
|
||||||
|
|
||||||
The command map file provides the mapping between show command and parser file.
|
|
||||||
The format of the file is a list of objects. Each object supports a set of
|
|
||||||
keys that can be configured to provide granular control over how each command
|
|
||||||
is implemented.
|
|
||||||
|
|
||||||
Command map entries support the following keys:
|
|
||||||
|
|
||||||
#### command
|
|
||||||
|
|
||||||
The `command` key is required and specifies the actual CLI command to execute
|
|
||||||
on the target device. The output from the command is then passed to the parser
|
|
||||||
for further processing.
|
|
||||||
|
|
||||||
#### parser
|
|
||||||
|
|
||||||
The `parser` key provides the name of the parser used to accept the output from
|
|
||||||
the command. The parser value shoule be the command parser filename either
|
|
||||||
relative to `parser_templates/cli` or absolute path. This value is required.
|
|
||||||
|
|
||||||
#### engine
|
|
||||||
|
|
||||||
This key accepts one of two values, either `command_parser` or `textfsm_parser`.
|
|
||||||
This value instructs the the parsing function as to which parsing engine to
|
|
||||||
use to parse the output from the CLI command.
|
|
||||||
|
|
||||||
This key is not required and, if not provided, the engine will assumed to be
|
|
||||||
`command_parser`
|
|
||||||
|
|
||||||
#### groups
|
|
||||||
|
|
||||||
Commands can be contained in one (or more) groups to make it easy for playbook
|
|
||||||
designers to filter specific facts to retreive from the network device. The
|
|
||||||
`groups` key must be a list and contain the groups the this command should be
|
|
||||||
associated with.
|
|
||||||
|
|
||||||
#### pre_hook
|
|
||||||
|
|
||||||
The `pre_hook` key provides the path to the set of tasks to include prior
|
|
||||||
to running the command on the CLI. This is useful if there is a need to check
|
|
||||||
if a command is available or supported on a particular version.
|
|
||||||
|
|
||||||
#### post_hook
|
|
||||||
|
|
||||||
The `post_hook` key provides the path to the set of tasks to include after the
|
|
||||||
command has been run on the target device and its results have been parsed by
|
|
||||||
the parser.
|
|
||||||
|
|
||||||
## Arguments
|
|
||||||
|
|
||||||
### ios_get_facts_subset
|
|
||||||
|
|
||||||
Defines the subset of facts to collection when the `get_facts` function is
|
|
||||||
called. This value must be a list value and contain only the sub keys for the
|
|
||||||
facts you wish to return.
|
|
||||||
|
|
||||||
The default value is `default`
|
|
||||||
|
|
||||||
#### Aliases
|
|
||||||
|
|
||||||
* subset
|
|
||||||
|
|
||||||
#### Current supported values for subset are
|
|
||||||
|
|
||||||
* default
|
|
||||||
* all
|
|
||||||
* interfaces
|
|
||||||
* bgp
|
|
||||||
* lldp
|
|
||||||
|
|
||||||
### ios_get_facts_command_map
|
|
||||||
|
|
||||||
Defines the command / parser mapping file to use when the call to `get_facts`
|
|
||||||
is made by the playbook. Normally this value does not need to be modified but
|
|
||||||
can be used to pass a custom command map to the function.
|
|
||||||
|
|
||||||
The default value is `vars/get_facts_command_map.yaml`
|
|
||||||
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#
|
|
||||||
# (c) 2018 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2017 Ansible Project
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
#
|
|
||||||
# Make coding more python3-ish
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
INTERFACE_NAMES = {
|
|
||||||
'Gi': 'GigabitEthernet',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def expand_interface_name(name):
|
|
||||||
match = re.match('([a-zA-Z]*)', name)
|
|
||||||
if match and match.group(1) in INTERFACE_NAMES:
|
|
||||||
matched = match.group(1)
|
|
||||||
name = name.replace(matched, INTERFACE_NAMES[matched])
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
class FilterModule(object):
|
|
||||||
"""Filters for working with output from network devices"""
|
|
||||||
|
|
||||||
filter_map = {
|
|
||||||
'expand_interface_name': expand_interface_name
|
|
||||||
}
|
|
||||||
|
|
||||||
def filters(self):
|
|
||||||
return self.filter_map
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for ansible-network.cisco_ios
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
# Playbook to ingest config manager args into ios provider specific args
|
|
||||||
#
|
|
||||||
|
|
||||||
- name: convert config_manager_text
|
|
||||||
set_fact:
|
|
||||||
ios_config_text: "{{ config_manager_text }}"
|
|
||||||
when: config_manager_text is defined
|
|
||||||
|
|
||||||
- name: convert config_manager_file
|
|
||||||
set_fact:
|
|
||||||
ios_config_file: "{{ config_manager_file }}"
|
|
||||||
when: config_manager_file is defined
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
- name: validate ios_checkpoint_filename is defined
|
|
||||||
fail:
|
|
||||||
msg: "missing required var: ios_checkpoint_filename"
|
|
||||||
when: ios_checkpoint_filename is undefined
|
|
||||||
|
|
||||||
- name: get current files on disk
|
|
||||||
cli:
|
|
||||||
command: dir
|
|
||||||
register: ios_dir_listing
|
|
||||||
|
|
||||||
- name: remove old checkpoint file (if necessary)
|
|
||||||
cli:
|
|
||||||
command: "delete /force flash:/{{ ios_checkpoint_filename }}"
|
|
||||||
when: ios_checkpoint_filename in ios_dir_listing.stdout
|
|
||||||
|
|
||||||
# copy the current running-config to the local flash disk on the target device.
|
|
||||||
# This will be used both for restoring the current config if a failure happens
|
|
||||||
# as well as performing a configuration diff once the new config has been
|
|
||||||
# loaded.
|
|
||||||
- name: create a checkpoint of the current running-config
|
|
||||||
ios_command:
|
|
||||||
commands:
|
|
||||||
- command: "copy running-config flash:{{ ios_checkpoint_filename }}"
|
|
||||||
prompt: ["\\? "]
|
|
||||||
answer: "{{ ios_checkpoint_filename }}"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
- name: validate ios_checkpoint_filename is defined
|
|
||||||
fail:
|
|
||||||
msg: "missing required var: ios_checkpoint_filename"
|
|
||||||
when: ios_checkpoint_filename is undefined
|
|
||||||
|
|
||||||
- name: get current files on disk
|
|
||||||
cli:
|
|
||||||
command: dir
|
|
||||||
register: ios_dir_listing
|
|
||||||
|
|
||||||
- name: remove checkpoint file from remote device
|
|
||||||
cli:
|
|
||||||
command: "delete /force flash:/{{ ios_checkpoint_filename }}"
|
|
||||||
when: ios_checkpoint_filename in ios_dir_listing.stdout
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
- name: validate ios_checkpoint_filename is defined
|
|
||||||
fail:
|
|
||||||
msg: "missing required var: ios_checkpoint_filename"
|
|
||||||
when: ios_checkpoint_filename is undefined
|
|
||||||
|
|
||||||
- name: get current files on disk
|
|
||||||
cli:
|
|
||||||
command: dir
|
|
||||||
register: ios_dir_listing
|
|
||||||
|
|
||||||
- name: verify checkpoint file exists
|
|
||||||
fail:
|
|
||||||
msg: "missing checkpoint file {{ ios_checkpoing_filename }}"
|
|
||||||
when: ios_checkpoint_filename not in ios_dir_listing.stdout
|
|
||||||
|
|
||||||
- name: checkpoint configuration restore pre hook
|
|
||||||
include_tasks: "{{ ios_checkpoint_restore_pre_hook }}"
|
|
||||||
when: ios_checkpoint_restore_pre_hook is defined
|
|
||||||
|
|
||||||
- name: restore checkpoint configuration
|
|
||||||
cli:
|
|
||||||
command: "config replace flash:/{{ ios_checkpoint_filename }} force"
|
|
||||||
register: ios_rollback_results
|
|
||||||
|
|
||||||
- name: checkpoint configuration restore post hook
|
|
||||||
include_tasks: "{{ ios_checkpoint_restore_post_hook }}"
|
|
||||||
when: ios_checkpoint_restore_post_hook is defined
|
|
||||||
|
|
||||||
- name: remove checkpoint file from remote device
|
|
||||||
cli:
|
|
||||||
command: "delete /force flash:/{{ ios_checkpoint_filename }}"
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
---
|
|
||||||
- name: validate ios_config_text is defined
|
|
||||||
fail:
|
|
||||||
msg: "missing required arg: ios_config_text"
|
|
||||||
when: ios_config_text is undefined
|
|
||||||
|
|
||||||
- name: set the ios_config_temp_file name
|
|
||||||
set_fact:
|
|
||||||
ios_config_temp_file: "tmp_ansible"
|
|
||||||
|
|
||||||
- name: create temp working dir
|
|
||||||
tempfile:
|
|
||||||
state: directory
|
|
||||||
register: ios_config_temp_dir
|
|
||||||
|
|
||||||
- name: write the config text to disk
|
|
||||||
copy:
|
|
||||||
content: "{{ ios_config_text }}"
|
|
||||||
dest: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}"
|
|
||||||
|
|
||||||
- name: get current list of files on remote device
|
|
||||||
cli:
|
|
||||||
command: dir
|
|
||||||
register: ios_dir_listing
|
|
||||||
|
|
||||||
- name: remove temporary files from target device
|
|
||||||
cli:
|
|
||||||
command: "delete /force flash:/{{ ios_config_temp_file }}"
|
|
||||||
when: ios_config_temp_file in ios_dir_listing.stdout
|
|
||||||
|
|
||||||
- name: enable the ios scp server
|
|
||||||
cli:
|
|
||||||
command: "{{ line }}"
|
|
||||||
loop:
|
|
||||||
- configure terminal
|
|
||||||
- ip scp server enable
|
|
||||||
- end
|
|
||||||
loop_control:
|
|
||||||
loop_var: line
|
|
||||||
|
|
||||||
- name: copy configuration to device
|
|
||||||
net_put:
|
|
||||||
src: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}"
|
|
||||||
dest: "flash:/{{ ios_config_temp_file }}"
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: merge with current active configuration
|
|
||||||
cli:
|
|
||||||
command: "{{ line }}"
|
|
||||||
loop:
|
|
||||||
- "copy flash:/{{ ios_config_temp_file }} force"
|
|
||||||
- "delete /force flash:/{{ ios_config_temp_file }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: line
|
|
||||||
|
|
||||||
- name: remove local temp working dir
|
|
||||||
file:
|
|
||||||
path: "{{ ios_config_temp_dir.path }}"
|
|
||||||
state: absent
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
---
|
|
||||||
- name: validate ios_config_text is defined
|
|
||||||
fail:
|
|
||||||
msg: "missing required arg: ios_config_text"
|
|
||||||
when: ios_config_text is undefined
|
|
||||||
|
|
||||||
- name: set the ios_config_temp_file name
|
|
||||||
set_fact:
|
|
||||||
ios_config_temp_file: "tmp_ansible"
|
|
||||||
|
|
||||||
- name: create temp working dir
|
|
||||||
tempfile:
|
|
||||||
state: directory
|
|
||||||
register: ios_config_temp_dir
|
|
||||||
|
|
||||||
- name: write the config text to disk
|
|
||||||
copy:
|
|
||||||
content: "{{ ios_config_text }}"
|
|
||||||
dest: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}"
|
|
||||||
|
|
||||||
- name: get current list of files on remote device
|
|
||||||
cli:
|
|
||||||
command: dir
|
|
||||||
register: ios_dir_listing
|
|
||||||
|
|
||||||
- name: remove temporary files from target device
|
|
||||||
cli:
|
|
||||||
command: "delete /force flash:/{{ ios_config_temp_file }}"
|
|
||||||
when: ios_config_temp_file in ios_dir_listing.stdout and ios_config_remove_temp_files
|
|
||||||
|
|
||||||
- name: enable the ios scp server
|
|
||||||
cli:
|
|
||||||
command: "{{ line }}"
|
|
||||||
loop:
|
|
||||||
- configure terminal
|
|
||||||
- ip scp server enable
|
|
||||||
- end
|
|
||||||
loop_control:
|
|
||||||
loop_var: line
|
|
||||||
|
|
||||||
- name: copy configuration to device
|
|
||||||
net_put:
|
|
||||||
src: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}"
|
|
||||||
dest: "flash:/{{ ios_config_temp_file }}"
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: replace current active configuration
|
|
||||||
cli:
|
|
||||||
command: "{{ line }}"
|
|
||||||
loop:
|
|
||||||
- "config replace flash:/{{ ios_config_temp_file }} force"
|
|
||||||
- "delete /force flash:/{{ ios_config_temp_file }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: line
|
|
||||||
|
|
||||||
- name: remove local temp working dir
|
|
||||||
file:
|
|
||||||
path: "{{ ios_config_temp_dir.path }}"
|
|
||||||
state: absent
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
# this block is responsible for loading the configuration on to the target
|
|
||||||
# device line by line from config model.
|
|
||||||
- name: load configuration onto target device
|
|
||||||
block:
|
|
||||||
- name: load configuration lines into target device
|
|
||||||
block:
|
|
||||||
- name: extract banners from configs if present
|
|
||||||
extract_banners:
|
|
||||||
config: "{{ ios_config_text }}"
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- name: load configuration lines into target device except banner
|
|
||||||
cli_config:
|
|
||||||
config: "{{ result['config'] }}"
|
|
||||||
register: ios_config_output
|
|
||||||
|
|
||||||
- name: enter configuration mode
|
|
||||||
cli:
|
|
||||||
command: "configure terminal"
|
|
||||||
|
|
||||||
- name: load banner lines into target device
|
|
||||||
cli_command:
|
|
||||||
command: "{{ item }}"
|
|
||||||
sendonly: true
|
|
||||||
with_items: "{{ result['banners'] }}"
|
|
||||||
register: banner_config_output
|
|
||||||
|
|
||||||
- name: exit configuration mode
|
|
||||||
cli:
|
|
||||||
command: end
|
|
||||||
|
|
||||||
rescue:
|
|
||||||
- name: exit configuration mode
|
|
||||||
cli:
|
|
||||||
command: end
|
|
||||||
|
|
||||||
- name: set host failed
|
|
||||||
fail:
|
|
||||||
msg: "error loading configuration lines"
|
|
||||||
when: not ansible_check_mode
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
- name: set role basic facts
|
|
||||||
set_fact:
|
|
||||||
ansible_network_ios_path: "{{ role_path }}"
|
|
||||||
ansible_network_ios_version: "v2.7.0"
|
|
||||||
|
|
||||||
- name: display the role version to stdout
|
|
||||||
debug:
|
|
||||||
msg: "ansible_network.cisco_ios version is {{ ansible_network_ios_version }}"
|
|
||||||
|
|
||||||
- name: validate ansible_network_os == 'ios'
|
|
||||||
fail:
|
|
||||||
msg: "expected ansible_network_os to be `ios`, got `{{ ansible_network_os }}`"
|
|
||||||
when: ansible_network_os != 'ios'
|
|
||||||
|
|
||||||
- name: validate ansible_connection == 'network_cli'
|
|
||||||
fail:
|
|
||||||
msg: "expected ansible_network to be `network_cli`, got `{{ ansible_connection }}`"
|
|
||||||
when: ansible_connection != 'network_cli'
|
|
||||||
|
|
||||||
- name: Validate we have required installed version of dependent roles
|
|
||||||
verify_dependent_role_version:
|
|
||||||
role_path: "{{ role_path }}"
|
|
||||||
depends_map:
|
|
||||||
- name: 'ansible-network.network-engine'
|
|
||||||
version: "{{ ios_network_engine_req_ver_override }}"
|
|
||||||
when: ios_dependent_role_check is defined and ios_dependent_role_check
|
|
||||||
and ios_network_engine_req_ver_override is defined
|
|
||||||
|
|
||||||
- name: Validate we have required installed version of dependent roles from meta
|
|
||||||
verify_dependent_role_version:
|
|
||||||
role_path: "{{ role_path }}"
|
|
||||||
when: ios_dependent_role_check is defined and ios_dependent_role_check
|
|
||||||
and ios_network_engine_req_ver_override is not defined
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
- name: run cli command pre hook
|
|
||||||
include_tasks: "{{ ios_run_cli_command_pre_hook }}"
|
|
||||||
when: ios_run_cli_command_pre_hook is defined and ios_run_cli_command_pre_hook
|
|
||||||
|
|
||||||
- name: run command and parse output
|
|
||||||
cli:
|
|
||||||
command: "{{ ios_command }}"
|
|
||||||
parser: "{{ parser }}"
|
|
||||||
engine: "{{ ios_parser_engine | default(None) }}"
|
|
||||||
name: "{{ ios_name | default(None) }} "
|
|
||||||
with_first_found:
|
|
||||||
- files:
|
|
||||||
- "{{ ios_parser }}"
|
|
||||||
paths:
|
|
||||||
- "{{ playbook_dir }}/parser_templates/ios"
|
|
||||||
- "~/.ansible/ansible_network/parser_templates/ios"
|
|
||||||
- "/etc/ansible/ansible_network/parser_templates/ios"
|
|
||||||
- "{{ role_path }}/parser_templates"
|
|
||||||
loop_control:
|
|
||||||
loop_var: parser
|
|
||||||
|
|
||||||
- name: run cli command post hook
|
|
||||||
include_tasks: "{{ ios_run_cli_command_post_hook }}"
|
|
||||||
when: ios_run_cli_command_post_hook is defined and ios_run_cli_command_post_hook
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
---
|
|
||||||
- name: initialize function
|
|
||||||
include_tasks: includes/init.yaml
|
|
||||||
|
|
||||||
- name: validate ios_config_includes is defined
|
|
||||||
fail:
|
|
||||||
msg: "missing required arg: ios_config_includes"
|
|
||||||
when: ios_config_includes is undefined
|
|
||||||
|
|
||||||
- name: set ios checkpoint filename
|
|
||||||
set_fact:
|
|
||||||
ios_checkpoint_filename: "chk_ansible"
|
|
||||||
|
|
||||||
# initiate creating a checkpoint of the existing running-config
|
|
||||||
- name: create checkpoint of current configuration
|
|
||||||
include_tasks: "{{ role_path }}/includes/checkpoint/create.yaml"
|
|
||||||
|
|
||||||
- name: configure the target device
|
|
||||||
block:
|
|
||||||
# iterate over the set of includes to configure the device
|
|
||||||
- name: iterate over configuration tasks
|
|
||||||
include_tasks: "{{ task }}"
|
|
||||||
loop: "{{ ios_config_includes }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: task
|
|
||||||
|
|
||||||
rescue:
|
|
||||||
# since the host has failed during the configuration load, the role by
|
|
||||||
# default will initiate a restore sequence. the restore sequence will
|
|
||||||
# load the previous running-config with the replace option enabled.
|
|
||||||
- name: display message
|
|
||||||
debug:
|
|
||||||
msg: "error configuring device, starting rollback"
|
|
||||||
when: ios_config_rollback_enabled
|
|
||||||
|
|
||||||
- name: initiate configuration rollback
|
|
||||||
include_tasks: "{{ role_path }}/includes/checkpoint/restore.yaml"
|
|
||||||
|
|
||||||
- name: display message
|
|
||||||
debug:
|
|
||||||
msg: "successfully completed configuration rollback"
|
|
||||||
when: ios_config_rollback_enabled
|
|
||||||
|
|
||||||
- name: fail host due to config load error
|
|
||||||
fail:
|
|
||||||
msg: "error loading configuration onto target device"
|
|
||||||
|
|
||||||
- name: set the ios_active_config fact
|
|
||||||
set_fact:
|
|
||||||
ios_active_config: "cfg_ansible"
|
|
||||||
|
|
||||||
# check if any reminents are left over from a previous run and remove them
|
|
||||||
# prior to starting the configuration tasks.
|
|
||||||
- name: check if stale temporarary files exist on target device
|
|
||||||
cli:
|
|
||||||
command: dir
|
|
||||||
register: ios_dir_listing
|
|
||||||
|
|
||||||
- name: remove temporary files from target device
|
|
||||||
cli:
|
|
||||||
command: "delete /force flash:/{{ ios_active_config }}"
|
|
||||||
when: ios_active_config in ios_dir_listing.stdout
|
|
||||||
|
|
||||||
# copy the updated running-config to the local flash device to be used to
|
|
||||||
# generate a configuration diff between the before and after
|
|
||||||
# running-configurations.
|
|
||||||
- name: copy running-config to active config
|
|
||||||
ios_command:
|
|
||||||
commands:
|
|
||||||
- command: "copy running-config flash:{{ ios_active_config }}"
|
|
||||||
prompt: ["\\? "]
|
|
||||||
answer: "{{ ios_active_config }}"
|
|
||||||
|
|
||||||
# generate the configuration diff and display the diff to stdout. only set
|
|
||||||
# changed if there are lines in the diff that have changed
|
|
||||||
- name: generate ios diff
|
|
||||||
cli:
|
|
||||||
command: "show archive config differences flash:{{ ios_checkpoint_filename }} flash:{{ ios_active_config }}"
|
|
||||||
register: ios_config_diff
|
|
||||||
changed_when: "'No changes were found' not in ios_config_diff.stdout"
|
|
||||||
|
|
||||||
- name: display config diff
|
|
||||||
debug:
|
|
||||||
msg: "{{ ios_config_diff.stdout.splitlines() }}"
|
|
||||||
when: not ansible_check_mode
|
|
||||||
|
|
||||||
# refresh the list of files currently on the target network device flash
|
|
||||||
# drive and remote all temp files
|
|
||||||
- name: update local directory listing
|
|
||||||
cli:
|
|
||||||
command: dir
|
|
||||||
register: ios_dir_listing
|
|
||||||
|
|
||||||
- name: remove remote temp files from flash
|
|
||||||
cli:
|
|
||||||
command: "delete /force flash:/{{ filename }}"
|
|
||||||
loop:
|
|
||||||
- "{{ ios_active_config }}"
|
|
||||||
- "{{ ios_checkpoint_filename }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: filename
|
|
||||||
when: filename in ios_dir_listing.stdout
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
#!/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.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'network'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = """
|
|
||||||
---
|
|
||||||
module: ios_capabilities
|
|
||||||
version_added: "2.7"
|
|
||||||
short_description: Collect device capabilities from Cisco IOS
|
|
||||||
description:
|
|
||||||
- Collect basic fact capabilities from Cisco NX-OS devices and return
|
|
||||||
the capabilities as Ansible facts.
|
|
||||||
author:
|
|
||||||
- Ansible Netowrk Community (ansible-network)
|
|
||||||
options: {}
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = """
|
|
||||||
- facts:
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = """
|
|
||||||
"""
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible.module_utils.connection import Connection
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
""" main entry point for Ansible module
|
|
||||||
"""
|
|
||||||
argument_spec = {}
|
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
|
||||||
|
|
||||||
connection = Connection(module._socket_path)
|
|
||||||
facts = connection.get_capabilities()
|
|
||||||
facts = module.from_json(facts)
|
|
||||||
result = {
|
|
||||||
'changed': False,
|
|
||||||
'ansible_facts': {'cisco_ios': {'capabilities': facts['device_info']}}
|
|
||||||
}
|
|
||||||
module.exit_json(**result)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
#!/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.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'network'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = """
|
|
||||||
---
|
|
||||||
module: ios_command
|
|
||||||
version_added: "2.1"
|
|
||||||
author: "Peter Sprygada (@privateip)"
|
|
||||||
short_description: Run commands on remote devices running Cisco IOS
|
|
||||||
description:
|
|
||||||
- Sends arbitrary commands to an ios node and returns the results
|
|
||||||
read from the device. This module includes an
|
|
||||||
argument that will cause the module to wait for a specific condition
|
|
||||||
before returning or timing out if the condition is not met.
|
|
||||||
- This module does not support running commands in configuration mode.
|
|
||||||
Please use M(ios_config) to configure IOS devices.
|
|
||||||
extends_documentation_fragment: ios
|
|
||||||
notes:
|
|
||||||
- Tested against IOS 15.6
|
|
||||||
options:
|
|
||||||
commands:
|
|
||||||
description:
|
|
||||||
- List of commands to send to the remote ios device over the
|
|
||||||
configured provider. The resulting output from the command
|
|
||||||
is returned. If the I(wait_for) argument is provided, the
|
|
||||||
module is not returned until the condition is satisfied or
|
|
||||||
the number of retries has expired. If a command sent to the
|
|
||||||
device requires answering a prompt, it is possible to pass
|
|
||||||
a dict containing I(command), I(answer) and I(prompt).
|
|
||||||
Common answers are 'y' or "\\r" (carriage return, must be
|
|
||||||
double quotes). See examples.
|
|
||||||
required: true
|
|
||||||
wait_for:
|
|
||||||
description:
|
|
||||||
- List of conditions to evaluate against the output of the
|
|
||||||
command. The task will wait for each condition to be true
|
|
||||||
before moving forward. If the conditional is not true
|
|
||||||
within the configured number of retries, the task fails.
|
|
||||||
See examples.
|
|
||||||
aliases: ['waitfor']
|
|
||||||
version_added: "2.2"
|
|
||||||
match:
|
|
||||||
description:
|
|
||||||
- The I(match) argument is used in conjunction with the
|
|
||||||
I(wait_for) argument to specify the match policy. Valid
|
|
||||||
values are C(all) or C(any). If the value is set to C(all)
|
|
||||||
then all conditionals in the wait_for must be satisfied. If
|
|
||||||
the value is set to C(any) then only one of the values must be
|
|
||||||
satisfied.
|
|
||||||
default: all
|
|
||||||
choices: ['any', 'all']
|
|
||||||
version_added: "2.2"
|
|
||||||
retries:
|
|
||||||
description:
|
|
||||||
- Specifies the number of retries a command should by tried
|
|
||||||
before it is considered failed. The command is run on the
|
|
||||||
target device every retry and evaluated against the
|
|
||||||
I(wait_for) conditions.
|
|
||||||
default: 10
|
|
||||||
interval:
|
|
||||||
description:
|
|
||||||
- Configures the interval in seconds to wait between retries
|
|
||||||
of the command. If the command does not pass the specified
|
|
||||||
conditions, the interval indicates how long to wait before
|
|
||||||
trying the command again.
|
|
||||||
default: 1
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = r"""
|
|
||||||
tasks:
|
|
||||||
- name: run show version on remote devices
|
|
||||||
ios_command:
|
|
||||||
commands: show version
|
|
||||||
|
|
||||||
- name: run show version and check to see if output contains IOS
|
|
||||||
ios_command:
|
|
||||||
commands: show version
|
|
||||||
wait_for: result[0] contains IOS
|
|
||||||
|
|
||||||
- name: run multiple commands on remote nodes
|
|
||||||
ios_command:
|
|
||||||
commands:
|
|
||||||
- show version
|
|
||||||
- show interfaces
|
|
||||||
|
|
||||||
- name: run multiple commands and evaluate the output
|
|
||||||
ios_command:
|
|
||||||
commands:
|
|
||||||
- show version
|
|
||||||
- show interfaces
|
|
||||||
wait_for:
|
|
||||||
- result[0] contains IOS
|
|
||||||
- result[1] contains Loopback0
|
|
||||||
- name: run commands that require answering a prompt
|
|
||||||
ios_command:
|
|
||||||
commands:
|
|
||||||
- command: 'clear counters GigabitEthernet0/1'
|
|
||||||
prompt: 'Clear "show interface" counters on this interface \[confirm\]'
|
|
||||||
answer: 'y'
|
|
||||||
- command: 'clear counters GigabitEthernet0/2'
|
|
||||||
prompt: '[confirm]'
|
|
||||||
answer: "\r"
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = """
|
|
||||||
stdout:
|
|
||||||
description: The set of responses from the commands
|
|
||||||
returned: always apart from low level errors (such as action plugin)
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
stdout_lines:
|
|
||||||
description: The value of stdout split into a list
|
|
||||||
returned: always apart from low level errors (such as action plugin)
|
|
||||||
type: list
|
|
||||||
sample: [['...', '...'], ['...'], ['...']]
|
|
||||||
failed_conditions:
|
|
||||||
description: The list of conditionals that have failed
|
|
||||||
returned: failed
|
|
||||||
type: list
|
|
||||||
sample: ['...', '...']
|
|
||||||
"""
|
|
||||||
import re
|
|
||||||
import time
|
|
||||||
|
|
||||||
from ansible.module_utils.network.ios.ios import run_commands
|
|
||||||
from ansible.module_utils.network.ios.ios import ios_argument_spec, check_args
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible.module_utils.network.common.utils import ComplexList
|
|
||||||
from ansible.module_utils.network.common.parsing import Conditional
|
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
|
|
||||||
|
|
||||||
def to_lines(stdout):
|
|
||||||
for item in stdout:
|
|
||||||
if isinstance(item, string_types):
|
|
||||||
item = str(item).split('\n')
|
|
||||||
yield item
|
|
||||||
|
|
||||||
|
|
||||||
def parse_commands(module, warnings):
|
|
||||||
command = ComplexList(dict(
|
|
||||||
command=dict(key=True),
|
|
||||||
prompt=dict(),
|
|
||||||
answer=dict()
|
|
||||||
), module)
|
|
||||||
commands = command(module.params['commands'])
|
|
||||||
for item in list(commands):
|
|
||||||
configure_type = re.match(r'conf(?:\w*)(?:\s+(\w+))?', item['command'])
|
|
||||||
if module.check_mode:
|
|
||||||
if configure_type and configure_type.group(1) not in ('confirm', 'replace', 'revert', 'network'):
|
|
||||||
module.fail_json(
|
|
||||||
msg='ios_command does not support running config mode '
|
|
||||||
'commands. Please use ios_config instead'
|
|
||||||
)
|
|
||||||
return commands
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""main entry point for module execution
|
|
||||||
"""
|
|
||||||
argument_spec = dict(
|
|
||||||
commands=dict(type='list', required=True),
|
|
||||||
|
|
||||||
wait_for=dict(type='list', aliases=['waitfor']),
|
|
||||||
match=dict(default='all', choices=['all', 'any']),
|
|
||||||
|
|
||||||
retries=dict(default=10, type='int'),
|
|
||||||
interval=dict(default=1, type='int')
|
|
||||||
)
|
|
||||||
|
|
||||||
argument_spec.update(ios_argument_spec)
|
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec,
|
|
||||||
supports_check_mode=True)
|
|
||||||
|
|
||||||
result = {'changed': False}
|
|
||||||
|
|
||||||
warnings = list()
|
|
||||||
check_args(module, warnings)
|
|
||||||
commands = parse_commands(module, warnings)
|
|
||||||
result['warnings'] = warnings
|
|
||||||
|
|
||||||
wait_for = module.params['wait_for'] or list()
|
|
||||||
conditionals = [Conditional(c) for c in wait_for]
|
|
||||||
|
|
||||||
retries = module.params['retries']
|
|
||||||
interval = module.params['interval']
|
|
||||||
match = module.params['match']
|
|
||||||
|
|
||||||
while retries > 0:
|
|
||||||
responses = run_commands(module, commands)
|
|
||||||
|
|
||||||
for item in list(conditionals):
|
|
||||||
if item(responses):
|
|
||||||
if match == 'any':
|
|
||||||
conditionals = list()
|
|
||||||
break
|
|
||||||
conditionals.remove(item)
|
|
||||||
|
|
||||||
if not conditionals:
|
|
||||||
break
|
|
||||||
|
|
||||||
time.sleep(interval)
|
|
||||||
retries -= 1
|
|
||||||
|
|
||||||
if conditionals:
|
|
||||||
failed_conditions = [item.raw for item in conditionals]
|
|
||||||
msg = 'One or more conditional statements have not been satisfied'
|
|
||||||
module.fail_json(msg=msg, failed_conditions=failed_conditions)
|
|
||||||
|
|
||||||
result.update({
|
|
||||||
'changed': False,
|
|
||||||
'stdout': responses,
|
|
||||||
'stdout_lines': list(to_lines(responses))
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exit_json(**result)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright 2018 Red Hat
|
|
||||||
# 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.1',
|
|
||||||
'status': ['preview'],
|
|
||||||
'supported_by': 'network'}
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
|
||||||
module: ios_user_manager
|
|
||||||
short_description: Manage an aggregate of users in IOS device(s)
|
|
||||||
description:
|
|
||||||
- Allows the `cisco_ios` provider role to manage aggregate of users
|
|
||||||
by providing idempotency and other utility functions while running
|
|
||||||
the `configure_user` task
|
|
||||||
version_added: "2.7"
|
|
||||||
options:
|
|
||||||
new_users:
|
|
||||||
description:
|
|
||||||
- Aggregate of local users to be configured on IOS device(s)
|
|
||||||
required: true
|
|
||||||
user_config:
|
|
||||||
description:
|
|
||||||
- User config lines extracted from the devices' running-configuration
|
|
||||||
required: true
|
|
||||||
author:
|
|
||||||
- Nilashish Chakraborty (@NilashishC)
|
|
||||||
'''
|
|
||||||
RETURN = """
|
|
||||||
stdout:
|
|
||||||
description: Filtered set of users that should be configured on the device
|
|
||||||
returned: always apart from low-level errors (such as action plugin)
|
|
||||||
type: list
|
|
||||||
sample: [{"name": "ansible", "privilege": 15}, {"name": "test_user", "privilege": 15, "view": "sh_int"}]
|
|
||||||
"""
|
|
||||||
EXAMPLES = '''
|
|
||||||
- ios_user_manager:
|
|
||||||
new_users: "{{ users }}"
|
|
||||||
user_config: "{{ existing_user_config.stdout }}"
|
|
||||||
'''
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{install_date: 'Thu May 2 18:46:21 2019', version: v2.7.1}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
galaxy_info:
|
|
||||||
author: Ansible Network Community (ansible-network)
|
|
||||||
description: |
|
|
||||||
This role provides an implementation for automating the configuration of
|
|
||||||
Cisco IOS/IOS-XE devices. It provides implementations of Ansible Network
|
|
||||||
configuration abstractions.
|
|
||||||
company: Ansible
|
|
||||||
|
|
||||||
license: GPLv3
|
|
||||||
|
|
||||||
min_ansible_version: 2.7
|
|
||||||
|
|
||||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
|
||||||
# min_ansible_container_version:
|
|
||||||
|
|
||||||
# Optionally specify the branch Galaxy will use when accessing the GitHub
|
|
||||||
# repo for this role. During role install, if no tags are available,
|
|
||||||
# Galaxy will use this branch. During import Galaxy will access files on
|
|
||||||
# this branch. If Travis integration is configured, only notifications for this
|
|
||||||
# branch will be accepted. Otherwise, in all cases, the repo's default branch
|
|
||||||
# (usually master) will be used.
|
|
||||||
# github_branch:
|
|
||||||
|
|
||||||
#
|
|
||||||
# platforms is a list of platforms, and each platform has a name and a list of versions.
|
|
||||||
#
|
|
||||||
platforms:
|
|
||||||
- name: ios
|
|
||||||
version:
|
|
||||||
- any
|
|
||||||
|
|
||||||
galaxy_tags:
|
|
||||||
- network
|
|
||||||
- cisco
|
|
||||||
- ios
|
|
||||||
- iosxe
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
- src: ansible-network.network-engine
|
|
||||||
version: v2.7.3
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
---
|
|
||||||
- name: parser meta data
|
|
||||||
parser_metadata:
|
|
||||||
version: 1.0
|
|
||||||
command: show cdp neighbors detail
|
|
||||||
network_os: ios
|
|
||||||
|
|
||||||
- name: match sections
|
|
||||||
pattern_match:
|
|
||||||
regex: "^-----.*"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
register: context
|
|
||||||
|
|
||||||
- name: parse cdp neighbors
|
|
||||||
pattern_group:
|
|
||||||
- name: parse local port
|
|
||||||
pattern_match:
|
|
||||||
regex: '^Interface: ([^,]*)'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: local_port
|
|
||||||
|
|
||||||
- name: parse remote prort
|
|
||||||
pattern_match:
|
|
||||||
regex: 'Port ID \(outgoing port\): (.*)$'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: remote_port
|
|
||||||
|
|
||||||
- name: parse remote host
|
|
||||||
pattern_match:
|
|
||||||
regex: 'Device ID: (.*)$'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: remote_host
|
|
||||||
|
|
||||||
loop: "{{ context }}"
|
|
||||||
register: matches
|
|
||||||
|
|
||||||
- name: build cdp neighbor facts
|
|
||||||
loop: "{{ matches }}"
|
|
||||||
register: cdp
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
extend: "{{ toplevel | default('cisco_ios') }}"
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "{{ item.local_port.matches.0 | expand_interface_name }}"
|
|
||||||
object:
|
|
||||||
- key: neighbor
|
|
||||||
value: "{{ item.remote_host.matches.0 }}"
|
|
||||||
- key: neighbor_port
|
|
||||||
value: "{{ item.remote_port.matches.0 }}"
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
---
|
|
||||||
- name: parser meta data
|
|
||||||
parser_metadata:
|
|
||||||
version: 1.0
|
|
||||||
command: show interfaces
|
|
||||||
network_os: ios
|
|
||||||
|
|
||||||
- name: match sections
|
|
||||||
pattern_match:
|
|
||||||
regex: "^\\S+ is (up|down|administratively down),"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
register: context
|
|
||||||
|
|
||||||
- name: match interface values
|
|
||||||
pattern_group:
|
|
||||||
- name: match name
|
|
||||||
pattern_match:
|
|
||||||
regex: "^(\\S+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: name
|
|
||||||
|
|
||||||
- name: match hardware
|
|
||||||
pattern_match:
|
|
||||||
regex: "Hardware is (.*(?=,)|.*)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: type
|
|
||||||
|
|
||||||
- name: match mtu
|
|
||||||
pattern_match:
|
|
||||||
regex: "MTU (\\d+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: mtu
|
|
||||||
|
|
||||||
- name: match interface description
|
|
||||||
pattern_match:
|
|
||||||
regex: "Description: (.+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: description
|
|
||||||
|
|
||||||
- name: match administrative state
|
|
||||||
pattern_match:
|
|
||||||
regex: "(administratively down)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: enabled
|
|
||||||
|
|
||||||
- name: match line protocol
|
|
||||||
pattern_match:
|
|
||||||
regex: "line protocol is (\\S+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: operstatus
|
|
||||||
|
|
||||||
- name: match in packets
|
|
||||||
pattern_match:
|
|
||||||
regex: "(\\d+) packets input, (\\d+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: in_pkts_octets
|
|
||||||
|
|
||||||
- name: match input broadcast
|
|
||||||
pattern_match:
|
|
||||||
regex: "Received (\\d+) broadcasts \\(\\d+"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: in_bcast_mcast
|
|
||||||
|
|
||||||
- name: match out packets
|
|
||||||
pattern_match:
|
|
||||||
regex: "(\\d+) packets output, (\\d+) bytes"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: out_pkts_octets
|
|
||||||
|
|
||||||
- name: match out errors
|
|
||||||
pattern_match:
|
|
||||||
regex: "(\\d+) output errors"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: out_errors
|
|
||||||
|
|
||||||
loop: "{{ context }}"
|
|
||||||
register: values
|
|
||||||
|
|
||||||
- name: template interface values
|
|
||||||
loop: "{{ values }}"
|
|
||||||
register: interfaces
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
extend: cisco_ios
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "{{ item.name.matches.0 }}"
|
|
||||||
object:
|
|
||||||
- key: name
|
|
||||||
value: "{{ item.name.matches.0 }}"
|
|
||||||
- key: type
|
|
||||||
value: "{{ item.type.matches.0 }}"
|
|
||||||
- key: mtu
|
|
||||||
value: "{{ item.mtu.matches.0 }}"
|
|
||||||
- key: description
|
|
||||||
value: "{{ item.description.matches.0 }}"
|
|
||||||
- key: enabled
|
|
||||||
value: "{{ item.enabled.matches.0 is undefined }}"
|
|
||||||
- key: admin-status
|
|
||||||
value: "{{ item.enabled.matches.0 is undefined | ternary ('enabled', 'disabled') }}"
|
|
||||||
- key: oper-status
|
|
||||||
value: "{{ item.operstatus.matches.0 }}"
|
|
||||||
- key: counters
|
|
||||||
object:
|
|
||||||
- key: in-octets
|
|
||||||
value: "{{ item.in_pkts_octets.matches.0 }}"
|
|
||||||
- key: in-unicast-pkts
|
|
||||||
value: "{{ item.in_pkts_octets.matches.1 }}"
|
|
||||||
- key: in-broadcast-pkts
|
|
||||||
value: "{{ item.in_bcast_mcast.matches.0 }}"
|
|
||||||
- key: in-multicast-pkts
|
|
||||||
value: "{{ item.in_bcast_mcast.matches.1 }}"
|
|
||||||
- key: out-octets
|
|
||||||
value: "{{ item.out_pkts_octets.matches.0 }}"
|
|
||||||
- key: out-unicast-pkts
|
|
||||||
value: "{{ item.out_pkts_octets.matches.1 }}"
|
|
||||||
- key: out-errors
|
|
||||||
value: "{{ item.out_errors.matches.0 }}"
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
---
|
|
||||||
- name: parser meta data
|
|
||||||
parser_metadata:
|
|
||||||
version: 1.0
|
|
||||||
command: show interfaces transceiver
|
|
||||||
network_os: ios
|
|
||||||
|
|
||||||
- name: match sections
|
|
||||||
pattern_match:
|
|
||||||
regex: '(^\S{2}\d+/\d/\d+).*'
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
register: context
|
|
||||||
|
|
||||||
- name: match interface transceiver
|
|
||||||
pattern_group:
|
|
||||||
- name: match transceiver
|
|
||||||
pattern_match:
|
|
||||||
regex: '(^\S{2}\d+/\d/\d+)'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: transceiver
|
|
||||||
|
|
||||||
- name: match temperature
|
|
||||||
pattern_match:
|
|
||||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: temperature
|
|
||||||
|
|
||||||
- name: match voltage
|
|
||||||
pattern_match:
|
|
||||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: voltage
|
|
||||||
|
|
||||||
- name: match TxPower
|
|
||||||
pattern_match:
|
|
||||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: txpower
|
|
||||||
|
|
||||||
- name: match RxPower
|
|
||||||
pattern_match:
|
|
||||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: rxpower
|
|
||||||
|
|
||||||
- name: match Alarm
|
|
||||||
pattern_match:
|
|
||||||
regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: alarm
|
|
||||||
|
|
||||||
loop: "{{ context }}"
|
|
||||||
register: values
|
|
||||||
|
|
||||||
- name: template interface values
|
|
||||||
loop: "{{ values }}"
|
|
||||||
register: transceiver
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
extend: cisco_ios
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "{{ item.transceiver.matches.0 | expand_interface_name}}"
|
|
||||||
object:
|
|
||||||
- key: temperature
|
|
||||||
value: "{{ item.temperature.matches.1 }}"
|
|
||||||
- key: voltage
|
|
||||||
value: "{{ item.voltage.matches.2 }}"
|
|
||||||
- key: tx
|
|
||||||
value: "{{ item.txpower.matches.4 }}"
|
|
||||||
- key: rx
|
|
||||||
value: "{{ item.rxpower.matches.5 }}"
|
|
||||||
- key: alarm
|
|
||||||
value: "{{ item.rxpower.matches.6 }}"
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- name: show_ip_bgp_summary
|
|
||||||
parser_metadata:
|
|
||||||
version: 1.0
|
|
||||||
command: show ip bgp summary
|
|
||||||
network_os: ios
|
|
||||||
|
|
||||||
- name: match not active
|
|
||||||
register: not_active
|
|
||||||
pattern_match:
|
|
||||||
regex: "BGP not active"
|
|
||||||
match_all: true
|
|
||||||
|
|
||||||
- name: set_vars bgp state active
|
|
||||||
set_vars:
|
|
||||||
process_state: "active"
|
|
||||||
|
|
||||||
- name: set_vars bgp state not active
|
|
||||||
set_vars:
|
|
||||||
process_state: "not active"
|
|
||||||
when: "not_active.0.matches == 'BGP not active'"
|
|
||||||
|
|
||||||
- name: match sections
|
|
||||||
register: context
|
|
||||||
pattern_match:
|
|
||||||
regex: "Neighbor.+"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
when: process_state == 'active'
|
|
||||||
|
|
||||||
- name: match lines
|
|
||||||
register: lines
|
|
||||||
pattern_match:
|
|
||||||
regex: "^[0-9a-f.]+"
|
|
||||||
content: "{{ context.0 }}"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
when: process_state == 'active'
|
|
||||||
|
|
||||||
- name: match neighbors
|
|
||||||
register: matched_neighbors
|
|
||||||
loop: "{{ lines }}"
|
|
||||||
pattern_match:
|
|
||||||
regex: "(?P<ip>[0-9a-f.]+)\\s+(?P<version>\\d+)\\s+(?P<asn>\\d+)\\s+(?P<msgrcvd>\\d+)\\s+(?P<msgsent>\\d+)\\s+(?P<tblver>\\d+)\\s+(?P<inq>\\d+)\\s+(?P<outq>\\d+)\\s+(?P<timer>\\S+)\\s+(?P<state>\\S+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
when: process_state == 'active'
|
|
||||||
|
|
||||||
- name: template bgp values
|
|
||||||
extend: cisco_ios.vrf.DEFAULT.protocols
|
|
||||||
register: bgp
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "process_state"
|
|
||||||
value: "{{ process_state }}"
|
|
||||||
|
|
||||||
- name: template bgp neighbor entries
|
|
||||||
extend: cisco_ios.vrf.DEFAULT.protocols.bgp
|
|
||||||
register: neighbors
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
loop: "{{ matched_neighbors }}"
|
|
||||||
when: process_state == 'active'
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "{{ item.ip }}"
|
|
||||||
object:
|
|
||||||
- key: state_pfxrcd
|
|
||||||
value: "{{ item.state }}"
|
|
||||||
- key: asn
|
|
||||||
value: "{{ item.asn }}"
|
|
||||||
- key: timer
|
|
||||||
value: "{{ item.timer }}"
|
|
||||||
- key: ip_version
|
|
||||||
value: "{{ item.version }}"
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
- name: show_ip_vrf_detail
|
|
||||||
parser_metadata:
|
|
||||||
version: 1.0
|
|
||||||
command: show ip vrf detail
|
|
||||||
network_os: ios
|
|
||||||
|
|
||||||
- name: match vrf sections
|
|
||||||
register: vrf_section
|
|
||||||
pattern_match:
|
|
||||||
regex: "^VRF \\S+(?: \\(VRF Id = \\d+\\)|); default RD"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
|
|
||||||
- name: match vrf section values
|
|
||||||
loop: "{{ vrf_section }}"
|
|
||||||
register: vrf_section_values
|
|
||||||
pattern_group:
|
|
||||||
|
|
||||||
- name: match name
|
|
||||||
pattern_match:
|
|
||||||
regex: "^VRF (\\S+)(?: \\(VRF Id = \\d+\\)|); default RD"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: name
|
|
||||||
|
|
||||||
- name: match description
|
|
||||||
pattern_match:
|
|
||||||
regex: "^ Description: (.*)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: description
|
|
||||||
|
|
||||||
- name: match route distinguisher
|
|
||||||
pattern_match:
|
|
||||||
regex: ".*; default RD (\\d+:\\d+|<not set>)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: rd
|
|
||||||
|
|
||||||
- name: match interface section
|
|
||||||
pattern_match:
|
|
||||||
regex: "^ Interfaces:([\\s\\S]*)(?:Address family|VRF Table ID)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: false
|
|
||||||
register: interface_section
|
|
||||||
|
|
||||||
- name: match export route target section
|
|
||||||
pattern_match:
|
|
||||||
regex: "(?:No|)Export VPN route-target communities([\\s\\S]*) (?:No |)Import VPN"
|
|
||||||
content: "{{ item }}"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: false
|
|
||||||
register: export_rt_section
|
|
||||||
|
|
||||||
- name: match import route target section
|
|
||||||
pattern_match:
|
|
||||||
regex: "Import VPN route-target communities([\\s\\S]*) (?:No |)import"
|
|
||||||
content: "{{ item }}"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: false
|
|
||||||
register: import_rt_section
|
|
||||||
|
|
||||||
- name: match vrf nested section values
|
|
||||||
loop: "{{ vrf_section_values }}"
|
|
||||||
register: vrf_nested_section_values
|
|
||||||
loop_control:
|
|
||||||
loop_var: vrf_item
|
|
||||||
pattern_group:
|
|
||||||
|
|
||||||
- name: match vrf name
|
|
||||||
pattern_match:
|
|
||||||
regex: "(.*)"
|
|
||||||
content: "{{ vrf_item.name.matches.0 }}"
|
|
||||||
register: name
|
|
||||||
|
|
||||||
- name: match description
|
|
||||||
pattern_match:
|
|
||||||
regex: "(.*)"
|
|
||||||
content: "{{ vrf_item.description.matches.0 }}"
|
|
||||||
register: description
|
|
||||||
|
|
||||||
- name: match route distinguisher
|
|
||||||
pattern_match:
|
|
||||||
regex: "(.*)"
|
|
||||||
content: "{{ vrf_item.rd.matches.0 }}"
|
|
||||||
register: rd
|
|
||||||
|
|
||||||
- name: match interfaces
|
|
||||||
pattern_match:
|
|
||||||
regex: "\\s+(\\S+)\\s"
|
|
||||||
content: "{{ vrf_item.interface_section.0.matches }}"
|
|
||||||
match_all: true
|
|
||||||
register: interface
|
|
||||||
|
|
||||||
- name: match export route targets
|
|
||||||
pattern_match:
|
|
||||||
regex: "\\s+RT:(\\d+:\\d+)"
|
|
||||||
content: "{{ vrf_item.export_rt_section.0.matches }}"
|
|
||||||
match_all: true
|
|
||||||
register: export_rt
|
|
||||||
|
|
||||||
- name: match import route targets
|
|
||||||
pattern_match:
|
|
||||||
regex: "\\s+RT:(\\d+:\\d+)"
|
|
||||||
content: "{{ vrf_item.import_rt_section.0.matches }}"
|
|
||||||
match_all: true
|
|
||||||
register: import_rt
|
|
||||||
|
|
||||||
- name: template export json object
|
|
||||||
export: true
|
|
||||||
loop: "{{ vrf_nested_section_values }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: vrf_nested_item
|
|
||||||
register: vrf
|
|
||||||
extend: cisco_ios
|
|
||||||
export_as: dict
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "{{ vrf_nested_item.name.matches.0 }}"
|
|
||||||
object:
|
|
||||||
- key: name
|
|
||||||
value: "{{ vrf_nested_item.name.matches.0 }}"
|
|
||||||
- key: description
|
|
||||||
value: "{{ vrf_nested_item.description.matches.0 }}"
|
|
||||||
- key: rd
|
|
||||||
value: "{{ vrf_nested_item.rd.matches.0 }}"
|
|
||||||
- key: export_rt
|
|
||||||
elements: "{{ export_rt_item.matches }}"
|
|
||||||
repeat_for: "{{ vrf_nested_item.export_rt }}"
|
|
||||||
repeat_var: export_rt_item
|
|
||||||
- key: import_rt
|
|
||||||
elements: "{{ import_rt_item.matches }}"
|
|
||||||
repeat_for: "{{ vrf_nested_item.import_rt }}"
|
|
||||||
repeat_var: import_rt_item
|
|
||||||
- key: interface
|
|
||||||
elements: "{{ interface_item.matches }}"
|
|
||||||
repeat_for: "{{ vrf_nested_item.interface }}"
|
|
||||||
repeat_var: interface_item
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
---
|
|
||||||
- name: parser meta data
|
|
||||||
parser_metadata:
|
|
||||||
version: 1.0
|
|
||||||
command: show lldp neighbors detail
|
|
||||||
network_os: ios
|
|
||||||
|
|
||||||
- name: match sections
|
|
||||||
pattern_match:
|
|
||||||
regex: "^-----.*"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
register: context
|
|
||||||
|
|
||||||
- name: parse lldp neighbors
|
|
||||||
pattern_group:
|
|
||||||
- name: parse local port
|
|
||||||
pattern_match:
|
|
||||||
regex: "Local Intf: (.+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: local_port
|
|
||||||
|
|
||||||
- name: parse remote prort
|
|
||||||
pattern_match:
|
|
||||||
regex: "Port id: (.+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: remote_port
|
|
||||||
|
|
||||||
- name: parse remote host
|
|
||||||
pattern_match:
|
|
||||||
regex: "System Name: (.+)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: remote_host
|
|
||||||
|
|
||||||
loop: "{{ context }}"
|
|
||||||
register: matches
|
|
||||||
|
|
||||||
- name: build lldp neighbor facts
|
|
||||||
register: lldp
|
|
||||||
export: true
|
|
||||||
extend: "{{ toplevel | default('cisco_ios') }}"
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: neighbors
|
|
||||||
elements:
|
|
||||||
- key: port
|
|
||||||
value: "{{ item.local_port.matches.0 | expand_interface_name }}"
|
|
||||||
- key: neighbor
|
|
||||||
value: "{{ item.remote_host.matches.0 }}"
|
|
||||||
- key: neighbor_port
|
|
||||||
value: "{{ item.remote_port.matches.0 }}"
|
|
||||||
repeat_for: "{{ matches }}"
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
---
|
|
||||||
- name: parser meta data
|
|
||||||
parser_metadata:
|
|
||||||
version: 1.0
|
|
||||||
command: show version
|
|
||||||
network_os: ios
|
|
||||||
|
|
||||||
- name: match softare version
|
|
||||||
pattern_match:
|
|
||||||
regex: "Cisco IOS Software.*, Version (\\S+),"
|
|
||||||
register: version
|
|
||||||
|
|
||||||
- name: match model
|
|
||||||
pattern_match:
|
|
||||||
regex: "[Cc]isco (.+) \\("
|
|
||||||
register: model
|
|
||||||
|
|
||||||
- name: match hostname
|
|
||||||
pattern_match:
|
|
||||||
regex: "^(\\S+) uptime is"
|
|
||||||
register: hostname
|
|
||||||
|
|
||||||
- name: match image
|
|
||||||
pattern_match:
|
|
||||||
regex: "^System image file is (\\S+)"
|
|
||||||
register: image
|
|
||||||
|
|
||||||
- name: match restart conditions
|
|
||||||
pattern_match:
|
|
||||||
regex: "^System restarted at (?P<time>\\d+:\\d+:\\d+) (?P<tz>\\S+)"
|
|
||||||
register: restart_conditions
|
|
||||||
|
|
||||||
- name: match reload reason
|
|
||||||
pattern_match:
|
|
||||||
regex: "^Last reload reason: (\\S+)"
|
|
||||||
register: reload_reason
|
|
||||||
|
|
||||||
- name: match uptime
|
|
||||||
pattern_match:
|
|
||||||
regex: "uptime is (.+)"
|
|
||||||
register: uptime
|
|
||||||
|
|
||||||
- name: match uptime years
|
|
||||||
pattern_match:
|
|
||||||
regex: "uptime is (\\d+) year"
|
|
||||||
register: uptime_years
|
|
||||||
|
|
||||||
- name: match uptime weeks
|
|
||||||
pattern_match:
|
|
||||||
regex: "(\\d+) week"
|
|
||||||
register: uptime_weeks
|
|
||||||
|
|
||||||
- name: match uptime days
|
|
||||||
pattern_match:
|
|
||||||
regex: "(\\d+) day"
|
|
||||||
register: uptime_days
|
|
||||||
|
|
||||||
- name: match uptime hours
|
|
||||||
pattern_match:
|
|
||||||
regex: "(\\d+) hour"
|
|
||||||
register: uptime_hours
|
|
||||||
|
|
||||||
- name: match uptime minutes
|
|
||||||
pattern_match:
|
|
||||||
regex: "(\\d+) minute"
|
|
||||||
register: uptime_minutes
|
|
||||||
|
|
||||||
- name: match configuration register
|
|
||||||
pattern_match:
|
|
||||||
regex: "register is (.+)"
|
|
||||||
register: confreg
|
|
||||||
|
|
||||||
- name: build ios system state facts
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: version
|
|
||||||
value: "{{ version.matches.0 }}"
|
|
||||||
- key: hostname
|
|
||||||
value: "{{ hostname.matches.0 }}"
|
|
||||||
- key: image_file
|
|
||||||
value: "{{ image.matches.0 }}"
|
|
||||||
- key: model
|
|
||||||
value: "{{ model.matches.0 }}"
|
|
||||||
- key: restart_time
|
|
||||||
value: "{{ restart_conditions.time }}"
|
|
||||||
- key: restart_tz
|
|
||||||
value: "{{ restart_conditions.tz }}"
|
|
||||||
- key: reload_reason
|
|
||||||
value: "{{ reload_reason.matches.0 | lower }}"
|
|
||||||
- key: uptime
|
|
||||||
value: "{{ uptime.matches.0 }}"
|
|
||||||
- key: uptime_split
|
|
||||||
object:
|
|
||||||
- key: years
|
|
||||||
value: "{{ uptime_years.matches.0 | default(0) | int }}"
|
|
||||||
- key: weeks
|
|
||||||
value: "{{ uptime_weeks.matches.0 | default(0) | int }}"
|
|
||||||
- key: days
|
|
||||||
value: "{{ uptime_days.matches.0 | default(0) | int }}"
|
|
||||||
- key: hours
|
|
||||||
value: "{{ uptime_hours.matches.0 | default(0) | int }}"
|
|
||||||
- key: minutes
|
|
||||||
value: "{{ uptime_minutes.matches.0 | default(0) | int }}"
|
|
||||||
- key: configuration_register
|
|
||||||
value: "{{ confreg.matches.0 }}"
|
|
||||||
register: system
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
extend: cisco_ios
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
---
|
|
||||||
- name: match sections
|
|
||||||
pattern_match:
|
|
||||||
regex: "^ip"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
register: context
|
|
||||||
|
|
||||||
- name: match prefix values
|
|
||||||
pattern_group:
|
|
||||||
- name: match name
|
|
||||||
pattern_match:
|
|
||||||
regex: "ip prefix-list (?P<acl_name>.+): (\\d+) entries"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: name
|
|
||||||
|
|
||||||
- name: match entries
|
|
||||||
pattern_match:
|
|
||||||
regex: "seq (\\d+) (permit|deny) (\\S+)(?: (le|ge) (\\d+))*"
|
|
||||||
content: "{{ item }}"
|
|
||||||
match_all: true
|
|
||||||
register: entry
|
|
||||||
loop: "{{ context }}"
|
|
||||||
register: entries
|
|
||||||
|
|
||||||
- name: template entries
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: name
|
|
||||||
value: "{{ item.name.acl_name }}"
|
|
||||||
- key: entries
|
|
||||||
elements:
|
|
||||||
- key: sequence
|
|
||||||
value: "{{ it.matches.0 }}"
|
|
||||||
- key: action
|
|
||||||
value: "{{ it.matches.1 }}"
|
|
||||||
- key: prefix
|
|
||||||
value: "{{ it.matches.2 }}"
|
|
||||||
- key: operator
|
|
||||||
value: "{{ it.matches.4 }}"
|
|
||||||
- key: length
|
|
||||||
value: "{{ it.matches.5 }}"
|
|
||||||
repeat_for: "{{ item.entry }}"
|
|
||||||
repeat_var: it
|
|
||||||
register: prefix_list_list
|
|
||||||
export: true
|
|
||||||
loop: "{{ entries }}"
|
|
||||||
|
|
||||||
- name: template entries
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "{{ item.name.acl_name }}"
|
|
||||||
object:
|
|
||||||
- key: entries
|
|
||||||
elements:
|
|
||||||
- key: sequence
|
|
||||||
value: "{{ it.matches.0 }}"
|
|
||||||
- key: action
|
|
||||||
value: "{{ it.matches.1 }}"
|
|
||||||
- key: prefix
|
|
||||||
value: "{{ it.matches.2 }}"
|
|
||||||
- key: operator
|
|
||||||
value: "{{ it.matches.3 }}"
|
|
||||||
- key: length
|
|
||||||
value: "{{ it.matches.4 }}"
|
|
||||||
repeat_for: "{{ item.entry }}"
|
|
||||||
repeat_var: it
|
|
||||||
loop: "{{ entries }}"
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
extend: cisco_ios.config
|
|
||||||
register: prefix_list_dict
|
|
||||||
|
|
||||||
- name: template acl and prefix
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: acl
|
|
||||||
elements:
|
|
||||||
- key: acl_name
|
|
||||||
value: "{{ item.name.acl_name }}"
|
|
||||||
- key: prefix
|
|
||||||
value: "{{ it.matches.2 }}"
|
|
||||||
repeat_for: "{{ item.entry }}"
|
|
||||||
repeat_var: it
|
|
||||||
register: prefix_list_basic
|
|
||||||
export: true
|
|
||||||
loop: "{{ entries }}"
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
---
|
|
||||||
- name: match sections
|
|
||||||
pattern_match:
|
|
||||||
regex: "interface"
|
|
||||||
match_all: true
|
|
||||||
match_greedy: true
|
|
||||||
register: section
|
|
||||||
|
|
||||||
- name: match interface config values
|
|
||||||
pattern_group:
|
|
||||||
- name: match name
|
|
||||||
pattern_match:
|
|
||||||
regex: "interface (.*)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: name
|
|
||||||
|
|
||||||
- name: match description
|
|
||||||
pattern_match:
|
|
||||||
regex: "description (.*)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: description
|
|
||||||
|
|
||||||
- name: match admin state
|
|
||||||
pattern_match:
|
|
||||||
regex: "(shutdown)"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: enabled
|
|
||||||
|
|
||||||
- name: match ip_helper
|
|
||||||
pattern_match:
|
|
||||||
regex: "ip helper-address (.*)"
|
|
||||||
match_all: true
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: ip_helper
|
|
||||||
|
|
||||||
- name: match cdp enable
|
|
||||||
pattern_match:
|
|
||||||
regex: "(no) cdp enable"
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: cdp_enable
|
|
||||||
|
|
||||||
- name: match speed
|
|
||||||
pattern_match:
|
|
||||||
regex: 'speed (.+)'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: speed
|
|
||||||
|
|
||||||
- name: match duplex
|
|
||||||
pattern_match:
|
|
||||||
regex: 'duplex (.+)'
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: duplex
|
|
||||||
|
|
||||||
- name: match ip_address
|
|
||||||
pattern_match:
|
|
||||||
regex: "ip address (.*)"
|
|
||||||
match_all: true
|
|
||||||
content: "{{ item }}"
|
|
||||||
register: ip_address
|
|
||||||
loop: "{{ section }}"
|
|
||||||
register: values
|
|
||||||
|
|
||||||
- name: template interface values
|
|
||||||
loop: "{{ values }}"
|
|
||||||
register: interface-config
|
|
||||||
export: true
|
|
||||||
export_as: dict
|
|
||||||
extend: cisco_ios.config
|
|
||||||
json_template:
|
|
||||||
template:
|
|
||||||
- key: "{{ item.name.matches.0 }}"
|
|
||||||
object:
|
|
||||||
- key: name
|
|
||||||
value: "{{ item.name.matches.0 }}"
|
|
||||||
- key: ip_addess
|
|
||||||
value: "{{ item.ip_address | map(attribute='matches') | list }}"
|
|
||||||
- key: description
|
|
||||||
value: "{{ item.description.matches.0 }}"
|
|
||||||
- key: ip_helper
|
|
||||||
value: "{{ item.ip_helper | map(attribute='matches') | list }}"
|
|
||||||
- key: enabled
|
|
||||||
value: "{{ not item.enabled.matches }}"
|
|
||||||
- key: mtu
|
|
||||||
value: "{{ item.mtu.matches.0 }}"
|
|
||||||
- key: speed
|
|
||||||
value: "{{ item.speed.matches.0 }}"
|
|
||||||
- key: duplex
|
|
||||||
value: "{{ item.duplex.matches.0 }}"
|
|
||||||
- key: cdp
|
|
||||||
value: "{{ not item.cdp_enable.matches }}"
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
- name: parse hostname
|
|
||||||
pattern_match:
|
|
||||||
regex: "hostname (.+)"
|
|
||||||
register: hostname
|
|
||||||
|
|
||||||
- name: parse domain-name
|
|
||||||
pattern_match:
|
|
||||||
regex: "ip domain-name (.+)"
|
|
||||||
register: domain_name
|
|
||||||
|
|
||||||
- name: parse ip routing
|
|
||||||
pattern_match:
|
|
||||||
regex: "(ip routing)"
|
|
||||||
register: routing
|
|
||||||
|
|
||||||
- name: set global config facts
|
|
||||||
set_vars:
|
|
||||||
hostname: "{{ hostname.matches.0 }}"
|
|
||||||
domain_name: "{{ domain_name.matches.0 }}"
|
|
||||||
routing: "{{ routing.matches.0 is defined }}"
|
|
||||||
export: true
|
|
||||||
extend: cisco_ios.config
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
Value Required,Filldown ACL_TYPE (Standard|Extended)
|
|
||||||
Value Required,Filldown ACL_NAME (\S+)
|
|
||||||
Value LINE_NUM (\d+)
|
|
||||||
Value ACTION (permit|deny)
|
|
||||||
Value PROTOCOL ([a-z]+)
|
|
||||||
Value SRC_HOST (\d+\.\d+\.\d+\.\d+)
|
|
||||||
Value SRC_ANY (any)
|
|
||||||
Value SRC_NETWORK (\d+\.\d+\.\d+\.\d+)
|
|
||||||
Value SRC_WILDCARD (\d+\.\d+\.\d+\.\d+)
|
|
||||||
Value SRC_PORT_MATCH (eq|neq|range|lt|gt)
|
|
||||||
Value SRC_PORT ((?<!range\s).+?)
|
|
||||||
Value SRC_PORT_RANGE_START ((?<=range\s)\S+)
|
|
||||||
Value SRC_PORT_RANGE_END (\S+)
|
|
||||||
Value DST_HOST (\d+\.\d+\.\d+\.\d+)
|
|
||||||
Value DST_ANY (any)
|
|
||||||
Value DST_NETWORK (\d+\.\d+\.\d+\.\d+)
|
|
||||||
Value DST_WILDCARD (\d+\.\d+\.\d+\.\d+)
|
|
||||||
Value DST_PORT_MATCH (eq|neq|range|lt|gt)
|
|
||||||
Value DST_PORT ((?<!range\s).+?)
|
|
||||||
Value DST_PORT_RANGE_START ((?<=range\s)\S+)
|
|
||||||
Value DST_PORT_RANGE_END (\S+)
|
|
||||||
Value FLAGS_MATCH (match-all|match-any)
|
|
||||||
Value TCP_FLAG (((\+|-|)ack(\s*?)|(\+|-|)established(\s*?)|(\+|-|)fin(\s*?)|(\+|-|)fragments(\s*?)|(\+|-|)psh(\s*?)|(\+|-|)rst(\s*?)|(\+|-|)syn(\s*?)|urg(\s*?))+)
|
|
||||||
Value LOG (log-input|log)
|
|
||||||
Value TIME (\S+)
|
|
||||||
Value STATE (inactive|active)
|
|
||||||
Value MATCHES (\d+)
|
|
||||||
Value MATCH (\d+)
|
|
||||||
|
|
||||||
Start
|
|
||||||
^(Standard|Extended) -> Continue.Clearall
|
|
||||||
^${ACL_TYPE}\s+IP\s+access\s+list\s+${ACL_NAME}\s* -> Record
|
|
||||||
^\s+${LINE_NUM}\s+${ACTION}\s+${PROTOCOL}\s+(host\s+${SRC_HOST}|${SRC_ANY}|${SRC_NETWORK}\s+${SRC_WILDCARD})(\s+${SRC_PORT_MATCH}\s+|)(${SRC_PORT_RANGE_START}\s+${SRC_PORT_RANGE_END}|${SRC_PORT}|)\s+(host\s+${DST_HOST}|${DST_ANY}|${DST_NETWORK}\s+${DST_WILDCARD})(\s+${DST_PORT_MATCH}\s+(${DST_PORT_RANGE_START}\s+${DST_PORT_RANGE_END}|${DST_PORT}|)|\s+(${FLAGS_MATCH}\s+|)${TCP_FLAG}|)(\s+${LOG}|)(\s+time-range\s+${TIME}\s+\(${STATE}\)|)(?:\s+\(${MATCHES}\s+matches\)|)(?:\s+\(${MATCH}\s+match\)|)\s*$$ -> Record
|
|
||||||
^\s+${LINE_NUM}\s+${ACTION}\s+(${SRC_NETWORK},\s+wildcard\s+bits\s+${SRC_WILDCARD}|${SRC_HOST}|${SRC_ANY})(\s+${LOG}|)(\s+time-range\s+${TIME}\s+\(${STATE}\)|)(?:\s+\(${MATCHES}\s+matches\)|)\s*$$ -> Record
|
|
||||||
^.* -> Error "Could not parse line:"
|
|
||||||
|
|
||||||
EOF
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
Value src (\d+.\d+.\d+.\d+)
|
|
||||||
Value dst (\d+.\d+.\d+.\d+)
|
|
||||||
Value proto (\S+)
|
|
||||||
Value src_port (\d+)
|
|
||||||
Value dst_port (\d+)
|
|
||||||
Value num_packets (\d+)
|
|
||||||
|
|
||||||
Start
|
|
||||||
^.*permitted ${proto} ${src}\(${src_port}\)(?:\s|-|>)*${dst}\(${dst_port}\), ${num_packets} packet.* -> Record
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Run provider add host initiator tasks
|
|
||||||
include_tasks: "{{ role_path }}/tasks/cloud_vpn/providers/{{ cloud_vpn_initiator_provider }}/initiator/add_host.yaml"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Run provider add host responder tasks
|
|
||||||
include_tasks: "{{ role_path }}/tasks/cloud_vpn/providers/{{ cloud_vpn_responder_provider }}/responder/add_host.yaml"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Run provider configure routing initiator tasks
|
|
||||||
include_tasks: "{{ role_path }}/tasks/cloud_vpn/providers/{{ cloud_vpn_initiator_provider }}/initiator/configure_routing.yaml"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Run provider configure routing tasks
|
|
||||||
include_tasks: "{{ role_path }}/tasks/cloud_vpn/providers/{{ cloud_vpn_responder_provider }}/responder/configure_routing.yaml"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Run provider configure vpn initiator tasks
|
|
||||||
include_tasks: "{{ role_path }}/tasks/cloud_vpn/providers/{{ cloud_vpn_initiator_provider }}/initiator/configure_vpn.yaml"
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user