Ansible Galaxy: skel for network role #37241 (#37251)

* Skel for network role (#37241)

Skel and boilerplate for network role.

* Add network option as valid type
pull/37264/head
Victor da Costa 7 years ago committed by Chris Houseknecht
parent c2a063a5c0
commit cb53b717a4

@ -82,7 +82,7 @@ class GalaxyCLI(CLI):
self.parser.add_option('--init-path', dest='init_path', default="./", self.parser.add_option('--init-path', dest='init_path', default="./",
help='The path in which the skeleton role will be created. The default is the current working directory.') help='The path in which the skeleton role will be created. The default is the current working directory.')
self.parser.add_option('--type', dest='role_type', action='store', default='default', self.parser.add_option('--type', dest='role_type', action='store', default='default',
help="Initialize using an alternate role type. Valid types include: 'container', and 'apb'.") help="Initialize using an alternate role type. Valid types include: 'container', 'apb' and 'network'.")
self.parser.add_option('--role-skeleton', dest='role_skeleton', default=C.GALAXY_ROLE_SKELETON, self.parser.add_option('--role-skeleton', dest='role_skeleton', default=C.GALAXY_ROLE_SKELETON,
help='The path to a role skeleton that the new role should be based upon.') help='The path to a role skeleton that the new role should be based upon.')
elif self.action == "install": elif self.action == "install":

@ -0,0 +1,29 @@
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
install:
# Install ansible
- pip install ansible
# Check ansible version
- ansible --version
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses any vendor specific SDKs or module with specific dependencies, it may be a good idea to mention in this section that the package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

@ -0,0 +1,40 @@
#
# (c) 2018 Red Hat 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)
from ansible.errors import AnsibleError
__metaclass__ = type
try:
from ansible.plugins.cliconf import CliconfBase
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/cliconf/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/cliconf/junos.py
"""
except ImportError:
raise AnsibleError("Cliconf Plugin [ {{ role_name }} ]: Dependency not satisfied")
class Cliconf(CliconfBase):
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/cliconf/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/cliconf/junos.py
"""
raise AnsibleError("Cliconf Plugin [ {{ role_name }} ]: Not implemented")

@ -0,0 +1,2 @@
---
# defaults file for {{ role_name }}

@ -0,0 +1,71 @@
#
# (c) 2018 Red Hat 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)
from ansible.errors import AnsibleError
__metaclass__ = type
### Documentation
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_command.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_command.py
"""
EXAMPLES = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_command.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_command.py
"""
RETURN = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_command.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_command.py
"""
#### Imports
try:
from ansible.module_utils.basic import AnsibleModule
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_command.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_command.py
"""
except ImportError:
raise AnsibleError("[ {{ role_name }}_command ]: Dependency not satisfied")
#### Implementation
def main():
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_command.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_command.py
"""
raise AnsibleError(" [ {{ role_name }}_command ]: Not Implemented")
#### Entrypoint
if __name__ == '__main__':
main()

@ -0,0 +1,71 @@
#
# (c) 2018 Red Hat 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)
from ansible.errors import AnsibleError
__metaclass__ = type
### Documentation
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_config.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_config.py
"""
EXAMPLES = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_config.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_config.py
"""
RETURN = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_config.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_config.py
"""
### Imports
try:
from ansible.module_utils.basic import AnsibleModule
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_config.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_config.py
"""
except ImportError:
raise AnsibleError("[ {{ role_name }}_config ]: Dependency not satisfied")
### Implementation
def main():
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_config.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_config.py
"""
raise AnsibleError(" [ {{ role_name }}_config ]: Not Implemented")
### Entrypoint
if __name__ == '__main__':
main()

@ -0,0 +1,71 @@
#
# (c) 2018 Red Hat 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)
from ansible.errors import AnsibleError
__metaclass__ = type
### Documentation
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_facts.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_facts.py
"""
EXAMPLES = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_facts.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_facts.py
"""
RETURN = """
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_facts.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_facts.py
"""
### Imports
try:
from ansible.module_utils.basic import AnsibleModule
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_facts.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_facts.py
"""
except ImportError:
raise AnsibleError("[ {{ role_name }}_facts ]: Dependency not satisfied")
### Implementation
def main():
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/iosxr/iosxr_facts.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/network/junos/junos_facts.py
"""
raise AnsibleError(" [ {{ role_name }}_facts ]: Not Implemented")
### Entrypoint
if __name__ == '__main__':
main()

@ -0,0 +1,60 @@
galaxy_info:
author: {{ author }}
description: {{ description }}
company: {{ company }}
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: {{ issue_tracker_url }}
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: {{ license }}
min_ansible_version: {{ min_ansible_version }}
# 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: VYOS
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
{%- for dependency in dependencies %}
#- {{ dependency }}
{%- endfor %}

@ -0,0 +1,40 @@
#
# (c) 2018 Red Hat 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)
from ansible.errors import AnsibleError
__metaclass__ = type
### Imports
try:
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.connection import Connection
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/network/iosxr/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/network/junos//junos.py
"""
except ImportError:
raise AnsibleError("Netconf Plugin [ {{ role_name }} ]: Dependency not satisfied")
### Implementation
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/network/iosxr/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/network/junos//junos.py
"""

@ -0,0 +1,40 @@
#
# (c) 2018 Red Hat 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)
from ansible.errors import AnsibleError
__metaclass__ = type
try:
from ansible.plugins.terminal import NetconfBase
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/netconf/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/netconf/junos.py
"""
except ImportError:
raise AnsibleError("Netconf Plugin [ {{ role_name }} ]: Dependency not satisfied")
class Netconf(NetconfBase):
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/netconf/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/netconf/junos.py
"""
raise AnsibleError("Netconf Plugin [ {{ role_name }} ]: Not implemented")

@ -0,0 +1,2 @@
---
# tasks file for {{ role_name }}

@ -0,0 +1,40 @@
#
# (c) 2018 Red Hat 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)
from ansible.errors import AnsibleError
__metaclass__ = type
try:
from ansible.plugins.terminal import TerminalBase
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/terminal/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/terminal/junos.py
"""
except ImportError:
raise AnsibleError("Terminal Plugin [ {{ role_name }} ]: Dependency not satisfied")
class TerminalModule(TerminalBase):
"""
Examples:
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/terminal/iosxr.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/terminal/junos.py
"""
raise AnsibleError("Terminal Plugin [ {{ role_name }} ]: Not implemented")

@ -0,0 +1,14 @@
---
- hosts: localhost
connection: network_cli
gather_facts: False
roles:
- {{ role_name }}
- hosts: localhost
connection: netconf
gather_facts: False
roles:
- {{ role_name }}

@ -0,0 +1,2 @@
---
# vars file for {{ role_name }}
Loading…
Cancel
Save