├── roles └── netbird │ ├── tests │ ├── inventory │ └── test.yml │ ├── vars │ └── main.yml │ ├── handlers │ └── main.yml │ ├── defaults │ └── main.yml │ ├── tasks │ └── main.yml │ ├── README.md │ └── meta │ └── main.yml ├── tests └── unit │ ├── requirements.txt │ ├── module_utils │ └── inventories │ │ └── fixtures │ │ ├── invalid_token.json │ │ ├── groups_develoment.netbird.yml │ │ ├── only_connected.netbird.yml │ │ ├── ip_address.netbird.yml │ │ ├── netbird.yml │ │ ├── spaces_in_group.netbird.yml │ │ ├── peers.json │ │ ├── peers_multigroup.json │ │ └── peers_spaces_in_group.json │ └── plugins │ └── inventory │ └── test_netbird.py ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── config.yml │ └── bug.yml ├── workflows │ ├── run-ansible-unit-tests.yml │ ├── run-ansible-sanity-tests.yml │ ├── update-changelog.yml │ └── publish-to-ansible-galaxy.yml ├── CONTRIBUTING.md ├── CODE_OF_CONDUCT.md └── SECURITY.md ├── requirements.txt ├── plugins ├── README.md └── inventory │ └── netbird.py ├── meta └── runtime.yml ├── galaxy.yml ├── CHANGELOG.md ├── .gitignore ├── README.md └── LICENSE /roles/netbird/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/netbird/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for netbird 3 | -------------------------------------------------------------------------------- /roles/netbird/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for netbird 3 | -------------------------------------------------------------------------------- /tests/unit/requirements.txt: -------------------------------------------------------------------------------- 1 | requests>=2.31.0 2 | jsonpickle==3.0.3 3 | -------------------------------------------------------------------------------- /roles/netbird/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - netbird 6 | -------------------------------------------------------------------------------- /roles/netbird/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for netbird 3 | netbird_mgmt_url: https://api.netbird.io:443 4 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/invalid_token.json: -------------------------------------------------------------------------------- 1 | { 2 | "message": "token invalid", 3 | "code": 401 4 | } 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | open_collective: dominion-solutions-foss/projects/ansible-netbird 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | ansible>=9.2.0 2 | ansible-core>=2.16.3 3 | cffi==1.16.0 4 | cryptography==42.0.4 5 | epdb==0.15.1 6 | Jinja2==3.1.4 7 | jsonpickle==3.0.3 8 | MarkupSafe==2.1.5 9 | packaging==23.2 10 | pycparser==2.21 11 | PyYAML==6.0.1 12 | requests>=2.31.0 13 | resolvelib==1.0.1 14 | pytest-xdist==3.5.0 15 | pytest==8.0.0 16 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/groups_develoment.netbird.yml: -------------------------------------------------------------------------------- 1 | --- 2 | plugin: dominion_solutions.netbird.netbird 3 | api_url: https://api.netbird.io/api/ 4 | api_key: nbp_this_is_a_fake_api_key 5 | netbird_groups: 6 | - Development 7 | ip_style: plain 8 | groups: 9 | strict: No 10 | keyed_groups: 11 | compose: 12 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/only_connected.netbird.yml: -------------------------------------------------------------------------------- 1 | --- 2 | plugin: netbird 3 | api_key: nbp_this_is_a_fake_api_key 4 | api_url: https://netbird.example.com/api/v1 5 | ip_style: plain 6 | netbird_connected: True 7 | netbird_groups: 8 | groups: 9 | strict: No 10 | keyed_groups: 11 | compose: 12 | ansible_ssh_host: ip 13 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/ip_address.netbird.yml: -------------------------------------------------------------------------------- 1 | --- 2 | plugin: dominion_solutions.netbird.netbird 3 | api_key: nbp_this_is_a_fake_api_key 4 | api_url: https://netbird.example.com/api/v1 5 | ip_style: plain 6 | strict: No 7 | netbird_connected: No 8 | netbird_groups: 9 | groups: 10 | keyed_groups: 11 | compose: 12 | ansible_ssh_host: ip 13 | ansible_ssh_port: 22 14 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/netbird.yml: -------------------------------------------------------------------------------- 1 | --- 2 | plugin: dominion_solutions.netbird.netbird 3 | api_key: nbp_this_is_a_fake_api_key 4 | api_url: https://netbird.example.com/api/v1 5 | ip_style: plain 6 | netbird_connected: False 7 | leading_separator: No 8 | netbird_groups: 9 | - "All" 10 | groups: 11 | connected: connected 12 | ssh_hosts: ssh_enabled 13 | strict: No 14 | keyed_groups: 15 | compose: 16 | ansible_ssh_host: label 17 | ansible_ssh_port: 22 18 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/spaces_in_group.netbird.yml: -------------------------------------------------------------------------------- 1 | --- 2 | plugin: dominion_solutions.netbird.netbird 3 | api_key: nbp_this_is_a_fake_api_key 4 | api_url: https://netbird.example.com/api/v1 5 | ip_style: plain 6 | netbird_connected: False 7 | leading_separator: No 8 | netbird_groups: 9 | - "Test Group With Spaces" 10 | groups: 11 | connected: connected 12 | ssh_hosts: ssh_enabled 13 | strict: No 14 | keyed_groups: 15 | 16 | compose: 17 | ansible_ssh_host: label 18 | ansible_ssh_port: 22 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Ask a question 4 | url: https://github.com/dominion-solutions/ansible-netbird-role/discussions/new?category=q-a 5 | about: Ask the community for help 6 | - name: Request a feature 7 | url: https://github.com/dominion-solutions/ansible-netbird-role/discussions/new?category=ideas 8 | about: Share ideas for new features 9 | - name: Report a security issue 10 | url: https://github.com/dominion-solutions/ansible-netbird-role/security/policy 11 | about: Learn how to notify us for sensitive bugs 12 | -------------------------------------------------------------------------------- /.github/workflows/run-ansible-unit-tests.yml: -------------------------------------------------------------------------------- 1 | name: Run Ansible Unit Tests 2 | 3 | on: 4 | push: 5 | pull_request: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v4 16 | with: 17 | path: ansible_collections/dominion_solutions/netbird 18 | 19 | - name: Install dependencies 20 | run: | 21 | cd ansible_collections/dominion_solutions/netbird 22 | pip install -r requirements.txt 23 | 24 | - name: Run Ansible Unit Tests 25 | run: | 26 | cd ansible_collections/dominion_solutions/netbird 27 | ansible-test units 28 | -------------------------------------------------------------------------------- /.github/workflows/run-ansible-sanity-tests.yml: -------------------------------------------------------------------------------- 1 | name: Run Ansible Sanity Tests 2 | on: 3 | push: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | test: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v4 15 | with: 16 | path: ansible_collections/dominion_solutions/netbird 17 | 18 | - name: Install dependencies 19 | run: | 20 | cd ansible_collections/dominion_solutions/netbird 21 | pip install -r requirements.txt 22 | 23 | - name: Run Ansible Sanity Tests 24 | run: | 25 | cd ansible_collections/dominion_solutions/netbird 26 | ansible-test sanity 27 | -------------------------------------------------------------------------------- /roles/netbird/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for netbird 3 | - name: Check for Netbird Installation 4 | ansible.builtin.shell: 5 | cmd: netbird version 6 | ignore_errors: true 7 | register: netbird_installed 8 | 9 | - name: Install netbird 10 | ansible.builtin.shell: curl -fsSL https://pkgs.netbird.io/install.sh | sh 11 | when: netbird_installed.rc != 0 12 | 13 | - name: Ensure netbird is not up 14 | shell: 15 | cmd: 'netbird status | grep "Daemon status"' 16 | register: netbird_status 17 | changed_when: false 18 | ignore_errors: true 19 | when: netbird_register is true 20 | 21 | - name: Start Netbird 22 | become: true 23 | ansible.builtin.shell: netbird up --setup-key="{{ netbird_setup_key }}" --management-url="{{ netbird_mgmt_url }}" 24 | when: 25 | - netbird_register is true 26 | - "'NeedsLogin' in netbird_status.stdout or 'LoginFailed' in netbird_status.stdout" 27 | -------------------------------------------------------------------------------- /.github/workflows/update-changelog.yml: -------------------------------------------------------------------------------- 1 | name: "Update Changelog" 2 | on: 3 | release: 4 | types: [released] 5 | 6 | permissions: 7 | contents: write 8 | 9 | jobs: 10 | update: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v4 16 | with: 17 | ref: main 18 | token: ${{ secrets.DEVOPS_BOT_PAT }} 19 | 20 | - name: Update Changelog 21 | uses: stefanzweifel/changelog-updater-action@v1 22 | with: 23 | latest-version: ${{ github.event.release.name }} 24 | release-notes: ${{ github.event.release.body }} 25 | 26 | - name: Commit updated CHANGELOG 27 | uses: stefanzweifel/git-auto-commit-action@v5 28 | with: 29 | branch: main 30 | commit_message: Update CHANGELOG 31 | file_pattern: CHANGELOG.md 32 | push_options: --force 33 | -------------------------------------------------------------------------------- /plugins/README.md: -------------------------------------------------------------------------------- 1 | # Collections Plugins Directory 2 | 3 | This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that 4 | is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that 5 | would contain module utils and modules respectively. 6 | 7 | Here is an example directory of the majority of plugins currently supported by Ansible: 8 | 9 | ``` 10 | └── plugins 11 | ├── action 12 | ├── become 13 | ├── cache 14 | ├── callback 15 | ├── cliconf 16 | ├── connection 17 | ├── filter 18 | ├── httpapi 19 | ├── inventory 20 | ├── lookup 21 | ├── module_utils 22 | ├── modules 23 | ├── netconf 24 | ├── shell 25 | ├── strategy 26 | ├── terminal 27 | ├── test 28 | └── vars 29 | ``` 30 | 31 | A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible-core/2.16/plugins/plugins.html). 32 | -------------------------------------------------------------------------------- /.github/workflows/publish-to-ansible-galaxy.yml: -------------------------------------------------------------------------------- 1 | name: publish-to-ansible-galaxy 2 | on: 3 | release: 4 | types: [published] 5 | jobs: 6 | update-version-and-publish: 7 | permissions: 8 | contents: write 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | with: 13 | ref: main 14 | token: ${{ secrets.DEVOPS_BOT_PAT }} 15 | 16 | - name: Update version 17 | run: | 18 | echo "Updating version" 19 | sed -i "s/version: .*/version: ${{ github.event.release.tag_name }}/g" galaxy.yml 20 | 21 | - uses: stefanzweifel/git-auto-commit-action@v4 22 | with: 23 | commit_message: "Update galaxy.yml version to ${{ github.event.release.tag_name }}" 24 | branch: "main" 25 | file_pattern: "galaxy.yml" 26 | push_options: --force 27 | 28 | - uses: ansible/ansible-publish-action@v1.0.0 29 | with: 30 | api_key: ${{ secrets.ANSIBLE_GALAXY_API_KEY }} 31 | api_server: https://galaxy.ansible.com/api/ 32 | src_path: . 33 | -------------------------------------------------------------------------------- /roles/netbird/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | A role that installs the very basic version of Netbird, utilizing their install scripts. 4 | 5 | Requirements 6 | ------------ 7 | - curl 8 | 9 | Role Variables 10 | -------------- 11 | - `netbird_setup_key`: The key that is used to automate the setup process. 12 | - `netbird_register`: A true/false defining whether or not register netbird. 13 | - `netbird_mgmt_url`: The management URL for the self-hosted instance. If not specified, defaults to the cloud-hosted instance (https://api.netbird.io:443). 14 | 15 | Dependencies 16 | ------------ 17 | - None 18 | 19 | Example Playbook 20 | ---------------- 21 | ```yml 22 | --- 23 | - name: Install Netbird 24 | hosts: localhost 25 | become: true 26 | vars: 27 | netbird_setup_key: "{{ lookup('env', 'NETBIRD_SETUP_KEY') }}" 28 | netbird_register: true 29 | tasks: 30 | - name: Check for netbird setup key 31 | ansible.builtin.fail: 32 | msg: "netbird_setup_key is required" 33 | when: netbird_setup_key is not defined 34 | 35 | - name: Install Netbird 36 | ansible.builtin.include_role: 37 | name: netbird 38 | 39 | - name: Check Netbird Status 40 | ansible.builtin.shell: | 41 | netbird status --detail 42 | ``` 43 | 44 | License 45 | ------- 46 | MIT 47 | 48 | Author Information 49 | ------------------ 50 | - Mark J. Horninger 51 | - Many thanks to [Benjamin Arntzen](https://github.com/Zorlin) for his role that served as a guideline to build this role. 52 | -------------------------------------------------------------------------------- /meta/runtime.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Collections must specify a minimum required ansible version to upload 3 | # to galaxy 4 | requires_ansible: '>=2.16.0' 5 | 6 | # Content that Ansible needs to load from another location or that has 7 | # been deprecated/removed 8 | # plugin_routing: 9 | # action: 10 | # redirected_plugin_name: 11 | # redirect: ns.col.new_location 12 | # deprecated_plugin_name: 13 | # deprecation: 14 | # removal_version: "4.0.0" 15 | # warning_text: | 16 | # See the porting guide on how to update your playbook to 17 | # use ns.col.another_plugin instead. 18 | # removed_plugin_name: 19 | # tombstone: 20 | # removal_version: "2.0.0" 21 | # warning_text: | 22 | # See the porting guide on how to update your playbook to 23 | # use ns.col.another_plugin instead. 24 | # become: 25 | # cache: 26 | # callback: 27 | # cliconf: 28 | # connection: 29 | # doc_fragments: 30 | # filter: 31 | # httpapi: 32 | # inventory: 33 | # lookup: 34 | # module_utils: 35 | # modules: 36 | # netconf: 37 | # shell: 38 | # strategy: 39 | # terminal: 40 | # test: 41 | # vars: 42 | 43 | # Python import statements that Ansible needs to load from another location 44 | # import_redirection: 45 | # ansible_collections.ns.col.plugins.module_utils.old_location: 46 | # redirect: ansible_collections.ns.col.plugins.module_utils.new_location 47 | 48 | # Groups of actions/modules that take a common set of options 49 | # action_groups: 50 | # group_name: 51 | # - module1 52 | # - module2 53 | -------------------------------------------------------------------------------- /roles/netbird/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: Mark Horninger 3 | description: your role description 4 | company: Dominion Solutions LLC 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: MIT 18 | 19 | min_ansible_version: 9.2.0 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: 43 | - mesh 44 | - net 45 | - netbird 46 | - network 47 | - security 48 | - vpn 49 | - wireguard 50 | # List tags for your role here, one per line. A tag is a keyword that describes 51 | # and categorizes the role. Users find roles by searching for tags. Be sure to 52 | # remove the '[]' above, if you add tags to this list. 53 | # 54 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 55 | # Maximum 20 tags per role. 56 | 57 | dependencies: [] 58 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 59 | # if you add dependencies to this list. 60 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/peers.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "accessible_peers_count": 1, 4 | "approval_required": false, 5 | "connected": false, 6 | "dns_label": "apple.netbird.cloud", 7 | "groups": [ 8 | { 9 | "id": "2a3b4c5d6e7f8g9h0i1j", 10 | "name": "All", 11 | "peers_count": 2 12 | } 13 | ], 14 | "hostname": "apple", 15 | "id": "3a7b2c1d4e5f6g8h9i0j", 16 | "ip": "100.0.0.42", 17 | "last_login": "2024-02-10T22:01:27.744131502Z", 18 | "last_seen": "2024-02-11T03:21:42.202104672Z", 19 | "login_expiration_enabled": true, 20 | "login_expired": false, 21 | "name": "apple", 22 | "os": "Linux Mint 21.3", 23 | "ssh_enabled": true, 24 | "ui_version": "netbird-desktop-ui/0.25.7", 25 | "user_id": "auth0|ABC123xyz4567890", 26 | "version": "0.25.7" 27 | }, 28 | { 29 | "accessible_peers_count": 1, 30 | "approval_required": false, 31 | "connected": true, 32 | "dns_label": "banana.netbird.cloud", 33 | "groups": [ 34 | { 35 | "id": "2a3b4c5d6e7f8g9h0i1j", 36 | "name": "All", 37 | "peers_count": 2 38 | } 39 | ], 40 | "hostname": "banana", 41 | "id": "3a7b2c1d4e5f6g8h9i0j", 42 | "ip": "100.0.0.61", 43 | "last_login": "2024-02-02T11:20:05.934889112Z", 44 | "last_seen": "2024-02-16T16:14:35.853243309Z", 45 | "login_expiration_enabled": false, 46 | "login_expired": false, 47 | "name": "banana", 48 | "os": "Alpine Linux 3.19.1", 49 | "ssh_enabled": true, 50 | "ui_version": "", 51 | "user_id": "", 52 | "version": "0.25.5" 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/peers_multigroup.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "accessible_peers_count": 1, 4 | "approval_required": false, 5 | "city_name": "", 6 | "connected": false, 7 | "connection_ip": "", 8 | "country_code": "", 9 | "dns_label": "apple.netbird.cloud", 10 | "geoname_id": 0, 11 | "groups": [ 12 | { 13 | "id": "3aBcD4eF5gHiJ6kLmNoP", 14 | "name": "All", 15 | "peers_count": 2 16 | } 17 | ], 18 | "hostname": "apple", 19 | "id": "2j3k4l5m6n7o8p9q0r1", 20 | "ip": "10.10.10.123", 21 | "kernel_version": "", 22 | "last_login": "2024-02-10T22:01:27.744131502Z", 23 | "last_seen": "2024-02-11T03:21:42.202104672Z", 24 | "login_expiration_enabled": true, 25 | "login_expired": false, 26 | "name": "apple", 27 | "os": "Linux Mint 21.3", 28 | "ssh_enabled": false, 29 | "ui_version": "netbird-desktop-ui/0.25.7", 30 | "user_id": "auth0|abc123xyz4567890defg", 31 | "version": "0.25.7" 32 | }, 33 | { 34 | "accessible_peers_count": 1, 35 | "approval_required": false, 36 | "city_name": "New York", 37 | "connected": true, 38 | "connection_ip": "146.123.45.67", 39 | "country_code": "US", 40 | "dns_label": "banana.netbird.cloud", 41 | "geoname_id": 1234567, 42 | "groups": [ 43 | { 44 | "id": "2j3k4l5m6n7o8p9q0r1", 45 | "name": "Development", 46 | "peers_count": 1 47 | }, 48 | { 49 | "id": "3aBcD4eF5gHiJ6kLmNoP", 50 | "name": "All", 51 | "peers_count": 2 52 | } 53 | ], 54 | "hostname": "banana", 55 | "id": "hkwJPXNUmGywCLo5S8Wg", 56 | "ip": "10.10.10.124", 57 | "kernel_version": "", 58 | "last_login": "2024-02-02T11:20:05.934889112Z", 59 | "last_seen": "2024-02-24T02:59:35.324496386Z", 60 | "login_expiration_enabled": false, 61 | "login_expired": false, 62 | "name": "docker-manager", 63 | "os": "Alpine Linux 3.19.1", 64 | "ssh_enabled": false, 65 | "ui_version": "", 66 | "user_id": "", 67 | "version": "0.25.5" 68 | } 69 | ] 70 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to dominion_solutions.netbird 2 | 3 | Thank you for your interest in contributing to the `dominion_solutions.netbird` collection! We welcome contributions from the community to help improve and expand the functionality of this open source project. 4 | 5 | ## Getting Started 6 | 7 | To get started with contributing, please follow these steps: 8 | 9 | 1. Fork the repository on GitHub. 10 | 2. Clone your forked repository to your local machine. 11 | 3. Create a new branch for your changes. 12 | 4. Make your desired changes to the codebase. 13 | 5. Test your changes thoroughly. 14 | 6. Commit your changes with a descriptive commit message. 15 | 7. Push your changes to your forked repository. 16 | 8. Open a pull request on the original repository. 17 | 18 | ## Code Style and Guidelines 19 | 20 | Please ensure that your code adheres to the following guidelines: 21 | 22 | - Follow the [Ansible style guide](https://docs.ansible.com/ansible/latest/style_guide/index.html) for writing Ansible playbooks and roles. 23 | - Write clear and concise code with appropriate comments where necessary. 24 | - Use meaningful variable and function names. 25 | - Ensure that your code is properly formatted and indented. 26 | 27 | ## Reporting Issues 28 | 29 | If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository. When reporting an issue, please provide as much detail as possible, including steps to reproduce the issue and any relevant error messages. 30 | 31 | ## Contributing Documentation 32 | 33 | Improving the documentation is also a valuable contribution. If you find any areas of the documentation that can be enhanced or have ideas for new documentation, please feel free to contribute by opening a pull request. 34 | 35 | ## Code of Conduct 36 | 37 | Please note that by contributing to this project, you are expected to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md). Please be respectful and considerate towards others in all interactions. 38 | 39 | ## License 40 | 41 | By contributing to the `dominion_solutions.netbird` collection, you agree that your contributions will be licensed under the [MIT License](LICENSE). 42 | 43 | We appreciate your contributions and look forward to your involvement in making `dominion_solutions.netbird` even better! 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Report an Issue or Bug with the Package 3 | title: "[Bug]: " 4 | labels: ["bug"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | We're sorry to hear you have a problem. Can you help us solve it by providing the following details. 10 | - type: textarea 11 | id: what-happened 12 | attributes: 13 | label: What happened? 14 | description: What did you expect to happen? 15 | placeholder: I cannot currently do X thing because when I do, it breaks X thing. 16 | validations: 17 | required: true 18 | - type: textarea 19 | id: how-to-reproduce 20 | attributes: 21 | label: How to reproduce the bug 22 | description: How did this occur, please add any config values used and provide a set of reliable steps if possible. 23 | placeholder: When I do X I see Y. 24 | validations: 25 | required: true 26 | - type: input 27 | id: package-version 28 | attributes: 29 | label: Package Version 30 | description: What version of our Package are you running? Please be as specific as possible 31 | placeholder: 0.1.5 32 | validations: 33 | required: true 34 | - type: input 35 | id: python-version 36 | attributes: 37 | label: Python Version 38 | description: What version of Python are you running? Please be as specific as possible 39 | placeholder: 3.10.12 40 | validations: 41 | required: true 42 | - type: input 43 | id: ansible-version 44 | attributes: 45 | label: Ansible Version 46 | description: What version of Ansible Core are you running? Please be as specific as possible 47 | placeholder: 2.16.4 48 | validations: 49 | required: true 50 | - type: dropdown 51 | id: operating-systems 52 | attributes: 53 | label: Which operating systems does with happen with? 54 | description: You may select more than one. 55 | multiple: true 56 | options: 57 | - macOS 58 | - Windows 59 | - Linux 60 | - BSD 61 | - type: textarea 62 | id: notes 63 | attributes: 64 | label: Notes 65 | description: Use this field to provide any other notes that you feel might be relevant to the issue. 66 | validations: 67 | required: false 68 | -------------------------------------------------------------------------------- /tests/unit/module_utils/inventories/fixtures/peers_spaces_in_group.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "accessible_peers_count": 1, 4 | "approval_required": false, 5 | "city_name": "", 6 | "connected": false, 7 | "connection_ip": "", 8 | "country_code": "", 9 | "dns_label": "apple.netbird.cloud", 10 | "geoname_id": 0, 11 | "groups": [ 12 | { 13 | "id": "3aBcD4eF5gHiJ6kLmNoP", 14 | "name": "All", 15 | "peers_count": 2 16 | }, 17 | { 18 | "id": "2j3k4l5m6n7o8p9q0r1", 19 | "name": "Test Group With Spaces", 20 | "peers_count": 1 21 | } 22 | ], 23 | "hostname": "apple", 24 | "id": "2j3k4l5m6n7o8p9q0r1", 25 | "ip": "10.10.10.123", 26 | "kernel_version": "", 27 | "last_login": "2024-02-10T22:01:27.744131502Z", 28 | "last_seen": "2024-02-11T03:21:42.202104672Z", 29 | "login_expiration_enabled": true, 30 | "login_expired": false, 31 | "name": "apple", 32 | "os": "Linux Mint 21.3", 33 | "ssh_enabled": false, 34 | "ui_version": "netbird-desktop-ui/0.25.7", 35 | "user_id": "auth0|abc123xyz4567890defg", 36 | "version": "0.25.7" 37 | }, 38 | { 39 | "accessible_peers_count": 1, 40 | "approval_required": false, 41 | "city_name": "New York", 42 | "connected": true, 43 | "connection_ip": "146.123.45.67", 44 | "country_code": "US", 45 | "dns_label": "banana.netbird.cloud", 46 | "geoname_id": 1234567, 47 | "groups": [ 48 | { 49 | "id": "2j3k4l5m6n7o8p9q0r1", 50 | "name": "Development", 51 | "peers_count": 1 52 | }, 53 | { 54 | "id": "3aBcD4eF5gHiJ6kLmNoP", 55 | "name": "All", 56 | "peers_count": 2 57 | } 58 | ], 59 | "hostname": "banana", 60 | "id": "hkwJPXNUmGywCLo5S8Wg", 61 | "ip": "10.10.10.124", 62 | "kernel_version": "", 63 | "last_login": "2024-02-02T11:20:05.934889112Z", 64 | "last_seen": "2024-02-24T02:59:35.324496386Z", 65 | "login_expiration_enabled": false, 66 | "login_expired": false, 67 | "name": "docker-manager", 68 | "os": "Alpine Linux 3.19.1", 69 | "ssh_enabled": false, 70 | "ui_version": "", 71 | "user_id": "", 72 | "version": "0.25.5" 73 | } 74 | ] 75 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Dominion Solutions Netbird Collection Code of Conduct 2 | 3 | As contributors and maintainers of the Dominion Solutions Netbird Collection, we pledge to create a welcoming and inclusive environment for everyone. We value the participation of individuals from all backgrounds and experience levels and want to ensure a respectful and harassment-free experience for everyone involved. 4 | 5 | ## Our Standards 6 | 7 | To achieve a positive and inclusive community, we have established the following standards for all participants: 8 | 9 | ### 1. Be Respectful 10 | 11 | Treat others with respect and kindness. Be considerate of differing opinions and experiences. Remember that a diverse community is a strong community. 12 | 13 | ### 2. Be Inclusive 14 | 15 | Welcome and support individuals of all backgrounds and identities. Foster an environment where everyone feels safe to participate and contribute. 16 | 17 | ### 3. Be Collaborative 18 | 19 | Encourage collaboration and teamwork. Value the contributions of others and work together to achieve common goals. 20 | 21 | ### 4. Be Professional 22 | 23 | Maintain professionalism in all interactions. Avoid personal attacks, derogatory language, and any form of harassment or discrimination. 24 | 25 | ### 5. Be Open-Minded 26 | 27 | Embrace new ideas and perspectives. Be open to constructive feedback and willing to learn from others. 28 | 29 | ## Unacceptable Behavior 30 | 31 | The following behaviors are considered unacceptable within the Dominion Solutions Netbird Collection community: 32 | 33 | - Harassment, discrimination, or any form of offensive or disrespectful behavior. 34 | - Intimidation, threats, or personal attacks. 35 | - Publishing or sharing of private or sensitive information without consent. 36 | - Any form of spamming or trolling. 37 | - Any other behavior that violates the principles outlined in this Code of Conduct. 38 | 39 | ## Reporting Violations 40 | 41 | If you witness or experience any behavior that violates this Code of Conduct, please report it to the project maintainers at . All reports will be reviewed and investigated promptly and confidentially. We are committed to taking appropriate action to address any violations. 42 | 43 | ## Enforcement 44 | 45 | Maintainers of the Dominion Solutions Netbird Collection have the right and responsibility to remove, edit, or reject any contributions, comments, or other interactions that do not align with this Code of Conduct. Instances of abusive, harassing, or otherwise unacceptable behavior may result in temporary or permanent bans from the community. 46 | 47 | ## Attribution 48 | 49 | This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html). 50 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | If you discover any security related issues, please email compliance@dominion.solutions instead of using the issue tracker. 4 | Please encrypt messages using our PGP Key below: 5 | ``` 6 | -----BEGIN PGP PUBLIC KEY BLOCK----- 7 | 8 | mQGNBGXZ4joBDADKC9XF05nU53n5EXE0JM0G2FrhZaPEpzJ47CFcOyvx3eHTOfwN 9 | Z+Rtjgcugk66VNdj/fkwPpjj+Yj1ISchGDhOCXVlNnwiRdknGJ8uHZXlVYuPsVSF 10 | voocOthFuRgM8CighScO4uPybHZUa4VwQ2+B48WFa/3FszLf6YlDWoBwljE3KVZD 11 | WgTy/VvXx3Momwk+cher6W2eA8SuJEuixeX9mx7iu5kCjcvPBmvnDTfQS9zjKCuD 12 | ymwJg9h+paFFcx+ObmdOnpoG7jiB4kXENFtaAIrYR/vroODZZQUnBGvvEASXbJh6 13 | drEQu8t14l+qqaBCeGIbp/rM875VZPH7StAKRAhYGCr474Wj31jN9v93njnJtX5K 14 | gmBSyugI/FUOP+Eov7Fp4gvm7Mrupa/z01iRcomp7qCzOEmopE+Jx7Yj3ek79LWx 15 | 1YpCaYxbp4uAg0Qtk3A8fAm/7YwoJbsNCwh8fPUfyi6JTwomejJD1jA7IR+PBaX3 16 | pzFq9TLlzJlHsyMAEQEAAbRDRG9taW5pb24gU29sdXRpb25zIENvbXBsaWFuY2Ug 17 | R3JvdXAgPGNvbXBsaWFuY2VAZG9taW5pb24uc29sdXRpb25zPokB1AQTAQoAPhYh 18 | BNFjAqujHtMbhkYJGnpssxhf2tTABQJl2eI6AhsDBQkDwmcABQsJCAcCBhUKCQgL 19 | AgQWAgMBAh4BAheAAAoJEHpssxhf2tTABYUMAI8BAnA9sMhQD0M8Gv5Pt2dSt5Ok 20 | nQDS8zqTxZiwX5Fm+o7UOuKP+JK1RVwu3n/6XoM1G276dRwp05FJl7Qk36E5DxFU 21 | 29W4lPnvbvdJFRGbkb5JqaVnDnc/cobsytfu6qUDZPoJ6H41XgGdcQ43BuqLoux3 22 | z5kmnWr7uUg9SZZJR2q+RMbAsSHQuepRRmQj5ONmrHZaGIYTP5D9yblotsIcXQ98 23 | 5gb5qKIges+LyBdZPONP+YiJdwH3whAw6sljgpSaF0xBPLJnvy4LpBOb4/wThh0C 24 | pL1y+avi/fjCe2RSeAHxk9kiEyid4OPZNJx500g7jfFnLst0stct/QFLW8kenYyb 25 | bUe/oBWWYuxhh/XQR7YkezgUcIXjbLQFPXbDakQoc7yKrI1HGP6aHjLQis2hbXiH 26 | YrFc289vY1XuFlZaTP7rwmrabRi+lK6S5HX44aM3LmsSsL0s9sh6DhI27qqBrfsW 27 | Tsh+fojeANNFvx75fI6/DT8RZbz4cHmKTIQoFLkBjQRl2eI6AQwAwgDv1oraOTap 28 | HXwNdGJG9G8XIbie4w0iEhhIMpqiwbfrhBYDVKG+W9zoOzy5uu4D9OrnijFQgBlw 29 | 5gYqdmfHbpFDse1o0IMKYf+D/K9Ju/ZumBJHyI/SxkRT/MTkMmTW2Cse3sprujJO 30 | nvEyWt0PrT7ce/oJEfngjCIlPBoGdvAIoOToWi3+nqNHRksFaiMFV7151Sj3UWmb 31 | kd+VI9FooIgAvpr+c7mNkXBlASQGcm8ccaVseoKoi+EcLzZrnSFBAvYNDw/9fMue 32 | M1VsowkYjRmjhVqapRM2TVwlZhA9PBOwmcljYe7UXwF1rEpT6EkNKe2iL3cZ1PU6 33 | ElffLk3Gt7Y7BYOMftWY9d987jJhX0C8K5yygPtAG9hFlB+BEMNhNQlcSGKDRUfs 34 | W1rHLV2cHS9OUe8WLCKczZPCunuNQ7QTGSdOdgeMUps4MIWgauXNRFYBU+g4vYf8 35 | ibLaPACwMaGgj3CR4T5VaMx7c9DvOb6iKNT9kNje/CB/TXqW4S+lABEBAAGJAbwE 36 | GAEKACYWIQTRYwKrox7TG4ZGCRp6bLMYX9rUwAUCZdniOgIbDAUJA8JnAAAKCRB6 37 | bLMYX9rUwFjBC/4lO/cKl46AZ1+MwMrIMlb5/JCsa2uMloKllcnkufoqKSyW6yWk 38 | 0H7kqpsk4sSg53gGnfgIUrNo88FSac8OyMRmapbJRiq5kriJyJvadZdBpjVK/vAG 39 | PxdsRWeGFpnNz8eZOINbZBPg6/inLixloQeiJpMg11J2qVniGvqgPLTZ3AxmGUmL 40 | IDajBR7uYJgws0hw/pXGU1OQ5Z93472J44FxHMTRlTtA3AvCOLZ8v2O/wyBfKfpm 41 | x+0NpIauJ3pCerrsfpdwvftxubyBVtbsqvxLODBj79Pg6H+MPJN9aQeC3DNN9dA3 42 | ABRcFfFGpZ1u3Hh31xMo3+g1AGjl2E1wBliLy9wZwvJNtqX/gIqRFccYCNFNwama 43 | +sz87Je6Ykb350onCeKr6BtzU11A6RqXvdpFQQ3MQ1lDVF8J1XiXdKWE5X/KHjKR 44 | /5iPPc93z7ttRgcnJ5kEbHJPKMLMmMU7rTF6Af9+sxjgoolPTMzcjyek1ilVKdKv 45 | wNGl4zykRU8x8Qs= 46 | =9AAX 47 | -----END PGP PUBLIC KEY BLOCK----- 48 | ``` 49 | -------------------------------------------------------------------------------- /galaxy.yml: -------------------------------------------------------------------------------- 1 | ### REQUIRED 2 | # The namespace of the collection. This can be a company/brand/organization or product namespace under which all 3 | # content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with 4 | # underscores or numbers and cannot contain consecutive underscores 5 | namespace: dominion_solutions 6 | 7 | # The name of the collection. Has the same character restrictions as 'namespace' 8 | name: netbird 9 | 10 | # The version of the collection. Must be compatible with semantic versioning 11 | version: 0.3.0 12 | 13 | # The path to the Markdown (.md) readme file. This path is relative to the root of the collection 14 | readme: README.md 15 | 16 | # A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) 17 | # @nicks:irc/im.site#channel' 18 | authors: 19 | - Mark J. Horninger 20 | 21 | 22 | ### OPTIONAL but strongly recommended 23 | # A short summary description of the collection 24 | description: A collection of roles and playbooks for managing netbird peers. 25 | 26 | # The path to the license file for the collection. This path is relative to the root of the collection. This key is 27 | # mutually exclusive with 'license' 28 | license_file: LICENSE 29 | 30 | # A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character 31 | # requirements as 'namespace' and 'name' 32 | tags: 33 | - netbird 34 | - ansible 35 | - vpn 36 | - network 37 | - virtual 38 | - private 39 | 40 | # Collections that this collection requires to be installed for it to be usable. The key of the dict is the 41 | # collection label 'namespace.name'. The value is a version range 42 | # L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version 43 | # range specifiers can be set and are separated by ',' 44 | dependencies: {} 45 | 46 | # The URL of the originating SCM repository 47 | repository: https://github.com/dominion-solutions/ansible-netbird-role 48 | 49 | # The URL to any online docs 50 | documentation: https://github.com/dominion-solutions/ansible-netbird-role/blob/main/README.md 51 | 52 | # The URL to the homepage of the collection/project 53 | homepage: https://github.com/dominion-solutions/ansible-netbird-role 54 | 55 | # The URL to the collection issue tracker 56 | issues: https://github.com/dominion-solutions/ansible-netbird-role/issues 57 | 58 | # A list of file glob-like patterns used to filter any files or directories that should not be included in the build 59 | # artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This 60 | # uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', 61 | # and '.git' are always filtered. Mutually exclusive with 'manifest' 62 | build_ignore: [] 63 | 64 | # A dict controlling use of manifest directives used in building the collection artifact. The key 'directives' is a 65 | # list of MANIFEST.in style 66 | # L(directives,https://packaging.python.org/en/latest/guides/using-manifest-in/#manifest-in-commands). The key 67 | # 'omit_default_directives' is a boolean that controls whether the default directives are used. Mutually exclusive 68 | # with 'build_ignore' 69 | # manifest: null 70 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## Bug Fixes - Parameters - 2024-04-03 6 | 7 | ### Bug Fixes 8 | 9 | Thanks to @ipsecguy for pointing out that there was an issue with the compose variables. 10 | 11 | - #28 - The compose parameter is updated to accept a `dict()` now. 12 | - The documentation has been improved as well. 13 | - Some small issues around creating bugs / questions have been resolved. 14 | 15 | ### What's Changed 16 | 17 | * Update README.md by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird/pull/26 18 | * Fixes #28 - Tested with a separate inventory. by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird/pull/29 19 | 20 | **Full Changelog**: https://github.com/dominion-solutions/ansible-netbird/compare/0.1.6...0.2.0 21 | 22 | ## Fixed an accidental bug in the last release - 2024-03-11 23 | 24 | Bug was accidentally released in the last release. Fixed. 25 | 26 | ### What's Changed 27 | 28 | * Mjh/fix issues with message by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird/pull/24 29 | 30 | **Full Changelog**: https://github.com/dominion-solutions/ansible-netbird/compare/0.1.5...0.1.6 31 | 32 | ## Small Bugfixes - 2024-03-11 33 | 34 | Minor fixes including: 35 | 36 | - #14 Error on bad credentials. 37 | - #22 Wrapped bad urls in an AnsibleError 38 | - #20 The issue templates were bad. 39 | 40 | ### What's Changed 41 | 42 | * Mjh/14/error out on bad credentials by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird/pull/23 43 | 44 | **Full Changelog**: https://github.com/dominion-solutions/ansible-netbird/compare/0.1.4...0.1.5 45 | 46 | ## Documentation updates - 2024-03-01 47 | 48 | Closes #16 49 | 50 | ### What's Changed 51 | 52 | * Updated Readme in a big way. by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird/pull/17 53 | 54 | **Full Changelog**: https://github.com/dominion-solutions/ansible-netbird/compare/0.1.3...0.1.4 55 | 56 | ## Securtity Vulnerability Fixes - 2024-02-24 57 | 58 | Fixes security vulnerabilities 59 | 60 | ### What's Changed 61 | 62 | * Bump cryptography from 42.0.2 to 42.0.4 by @dependabot in https://github.com/dominion-solutions/ansible-netbird-role/pull/9 63 | * 'Fixed' Galaxy commit step by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird-role/pull/10 64 | * updated the steps to the galaxy.yml update gets included. by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird-role/pull/11 65 | 66 | ### New Contributors 67 | 68 | * @dependabot made their first contribution in https://github.com/dominion-solutions/ansible-netbird-role/pull/9 69 | 70 | **Full Changelog**: https://github.com/dominion-solutions/ansible-netbird-role/compare/0.1.2...0.1.3 71 | 72 | ## Security Vulnerability Fixes - 2024-02-24 73 | 74 | Fixes security vulnerabilities 75 | 76 | ### What's Changed 77 | 78 | * Bump cryptography from 42.0.2 to 42.0.4 by @dependabot in https://github.com/dominion-solutions/ansible-netbird-role/pull/9 79 | * 'Fixed' Galaxy commit step by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird-role/pull/10 80 | 81 | ### New Contributors 82 | 83 | * @dependabot made their first contribution in https://github.com/dominion-solutions/ansible-netbird-role/pull/9 84 | 85 | **Full Changelog**: https://github.com/dominion-solutions/ansible-netbird-role/compare/0.1.2...0.1.3 86 | 87 | ## [Bug] Not all groups being found - 2024-02-24 88 | 89 | This release fixes a critical bug where not all groups were being found during the list comprehension that was finding all of the groups. 90 | 91 | ### What's Changed 92 | 93 | * Fixed issues with the groups list comprehension by @spam-n-eggs in https://github.com/dominion-solutions/ansible-netbird-role/pull/8 94 | 95 | **Full Changelog**: https://github.com/dominion-solutions/ansible-netbird-role/compare/0.1.1...0.1.2 96 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/ansible,python,venv,virtualenv 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=ansible,python,venv,virtualenv 3 | 4 | ### Ansible ### 5 | *.retry 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | build/ 19 | develop-eggs/ 20 | dist/ 21 | downloads/ 22 | eggs/ 23 | .eggs/ 24 | lib/ 25 | lib64/ 26 | parts/ 27 | sdist/ 28 | var/ 29 | wheels/ 30 | share/python-wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | MANIFEST 35 | 36 | # PyInstaller 37 | # Usually these files are written by a python script from a template 38 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 39 | *.manifest 40 | *.spec 41 | 42 | # Installer logs 43 | pip-log.txt 44 | pip-delete-this-directory.txt 45 | 46 | # Unit test / coverage reports 47 | htmlcov/ 48 | .tox/ 49 | .nox/ 50 | .coverage 51 | .coverage.* 52 | .cache 53 | nosetests.xml 54 | coverage.xml 55 | *.cover 56 | *.py,cover 57 | .hypothesis/ 58 | .pytest_cache/ 59 | cover/ 60 | 61 | # Translations 62 | *.mo 63 | *.pot 64 | 65 | # Django stuff: 66 | *.log 67 | local_settings.py 68 | db.sqlite3 69 | db.sqlite3-journal 70 | 71 | # Flask stuff: 72 | instance/ 73 | .webassets-cache 74 | 75 | # Scrapy stuff: 76 | .scrapy 77 | 78 | # Sphinx documentation 79 | docs/_build/ 80 | 81 | # PyBuilder 82 | .pybuilder/ 83 | target/ 84 | 85 | # Jupyter Notebook 86 | .ipynb_checkpoints 87 | 88 | # IPython 89 | profile_default/ 90 | ipython_config.py 91 | 92 | # pyenv 93 | # For a library or package, you might want to ignore these files since the code is 94 | # intended to run in multiple environments; otherwise, check them in: 95 | # .python-version 96 | 97 | # pipenv 98 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 99 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 100 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 101 | # install all needed dependencies. 102 | #Pipfile.lock 103 | 104 | # poetry 105 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 106 | # This is especially recommended for binary packages to ensure reproducibility, and is more 107 | # commonly ignored for libraries. 108 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 109 | #poetry.lock 110 | 111 | # pdm 112 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 113 | #pdm.lock 114 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 115 | # in version control. 116 | # https://pdm.fming.dev/#use-with-ide 117 | .pdm.toml 118 | 119 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 120 | __pypackages__/ 121 | 122 | # Celery stuff 123 | celerybeat-schedule 124 | celerybeat.pid 125 | 126 | # SageMath parsed files 127 | *.sage.py 128 | 129 | # Environments 130 | .env 131 | .venv 132 | env/ 133 | venv/ 134 | ENV/ 135 | env.bak/ 136 | venv.bak/ 137 | 138 | # Spyder project settings 139 | .spyderproject 140 | .spyproject 141 | 142 | # Rope project settings 143 | .ropeproject 144 | 145 | # mkdocs documentation 146 | /site 147 | 148 | # mypy 149 | .mypy_cache/ 150 | .dmypy.json 151 | dmypy.json 152 | 153 | # Pyre type checker 154 | .pyre/ 155 | 156 | # pytype static type analyzer 157 | .pytype/ 158 | 159 | # Cython debug symbols 160 | cython_debug/ 161 | 162 | # PyCharm 163 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 164 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 165 | # and can be added to the global gitignore or merged into this file. For a more nuclear 166 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 167 | #.idea/ 168 | 169 | ### Python Patch ### 170 | # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration 171 | poetry.toml 172 | 173 | # ruff 174 | .ruff_cache/ 175 | 176 | # LSP config files 177 | pyrightconfig.json 178 | 179 | ### venv ### 180 | # Virtualenv 181 | # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ 182 | [Bb]in 183 | [Ii]nclude 184 | [Ll]ib 185 | [Ll]ib64 186 | [Ll]ocal 187 | [Ss]cripts 188 | pyvenv.cfg 189 | pip-selfcheck.json 190 | 191 | ### VirtualEnv ### 192 | # Virtualenv 193 | # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ 194 | 195 | # End of https://www.toptal.com/developers/gitignore/api/ansible,python,venv,virtualenv 196 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | dominion_solutions.netbird 2 | --- 3 | This collection allows you to manage your netbird servers. 4 | 5 | - [Required Python Libraries](#required-python-libraries) 6 | - [Roles](#roles) 7 | - [dominion\_solutions.netbird.netbird](#dominion_solutionsnetbirdnetbird) 8 | - [Inventories](#inventories) 9 | - [dominion\_solutions.netbird.netbird](#dominion_solutionsnetbirdnetbird-1) 10 | - [Sample Inventory Setups](#sample-inventory-setups) 11 | - [Retrieve All Netbird Peers in the _Development_ group](#retrieve-all-netbird-peers-in-the-development-group) 12 | - [Retrieve all Netbird Peers that _are Connected_](#retrieve-all-netbird-peers-that-are-connected) 13 | - [A More Complex example](#a-more-complex-example) 14 | - [Available data for custom groupings](#available-data-for-custom-groupings) 15 | - [Contributing](#contributing) 16 | - [Contributors](#contributors) 17 | 18 | 19 | # Required Python Libraries 20 | - ansible ~=9.2.0 21 | - requests ~=2.31.0 (If using the inventory plugin) 22 | 23 | # Roles 24 | ## dominion_solutions.netbird.netbird 25 | Applying this role will install the netbird client on the target machine. 26 | 27 | [Documentation](https://galaxy.ansible.com/ui/repo/published/dominion_solutions/netbird/content/role/netbird/) 28 | 29 | # Inventories 30 | ## dominion_solutions.netbird.netbird 31 | This is a dynamic inventory generated based on the configuration in the netbird API. 32 | 33 | [Documentation](https://galaxy.ansible.com/ui/repo/published/dominion_solutions/netbird/content/inventory/netbird/) 34 | 35 | ### Sample Inventory Setups 36 | #### Retrieve All Netbird Peers in the _Development_ group 37 | ```yaml 38 | --- 39 | plugin: dominion_solutions.netbird.netbird 40 | api_url: https://api.netbird.io/api/ 41 | api_key: nbp_this_is_a_fake_api_key 42 | netbird_groups: 43 | - Development 44 | strict: No 45 | ``` 46 | 47 | #### Retrieve all Netbird Peers that _are Connected_ 48 | ```yaml 49 | --- 50 | plugin: dominion_solutions.netbird.netbird 51 | api_key: nbp_this_is_a_fake_api_key 52 | api_url: https://netbird.example.com/api/ 53 | netbird_connected: True 54 | ``` 55 | 56 | #### A More Complex example 57 | This example gets all peers in the _All_ group and builds the additional _connected_ and _ssh\_hosts_ groups, based on the keys. 58 | ```yaml 59 | --- 60 | plugin: dominion_solutions.netbird.netbird 61 | api_key: nbp_this_is_a_fake_api_key 62 | api_url: https://netbird.example.com/api/ 63 | netbird_connected: False 64 | leading_separator: No 65 | netbird_groups: 66 | - "All" 67 | groups: 68 | connected: connected 69 | ssh_hosts: ssh_enabled 70 | strict: No 71 | keyed_groups: 72 | compose: 73 | ansible_ssh_host: label 74 | ansible_ssh_port: 22 75 | ``` 76 | ### Available data for custom groupings 77 | Fields are taken directly from the responses at the [Netbird Peers API](https://docs.netbird.io/api/resources/peers#list-all-peers) unless otherwise indicated 78 | 79 | | Field | Type | Notes | 80 | | ------------------------- | --------- | ----- | 81 | | label | `string` | `label` is a field generated as part of the inventory as an alias to the `dns_label` field. | 82 | | id | `string` | | 83 | | name | `string` | | 84 | | ip | `string` | | 85 | | connected | `boolean` | | 86 | | last_seen | `string` | This is is an [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) UTC Date Time String | 87 | | os | `string` | An OS Identifier such as `Linux Mint 21.3` or `Alpine Linux 3.19.1` | 88 | | version | `string` | The version of the Netbird Client that is running on the Peer | 89 | | groups | `object` | The groups object. This is parsed into the the groups in the inventory by name. | 90 | | enabled | `boolean` | | 91 | | user_id | `string` | | 92 | | hostname | `string` | The hostname part of the FQDN | 93 | | ui_version | `string` | Blank if there's no UI client installed, otherwise a version for the UI such as `netbird-desktop-ui/0.25.7` | 94 | | dns_label | `string` | The Fully Qualified Domain Name for this peer. | 95 | | login_expiration_enabled | `boolean` | Is this peer exempt from login expiration? | 96 | | login_expired | `boolean` | Is the login for this expired? | 97 | | last_login | `string` | | 98 | | approval_required | `boolean` | | 99 | | accessible_peers_count | `integer` | | 100 | 101 | # Contributing 102 | Please see [CONTRIBUTING.md](https://github.com/dominion-solutions/ansible-netbird/blob/main/.github/CONTRIBUTING.md) 103 | 104 | # Contributors 105 | - [Mark J. Horninger](https://github.com/spam-n-eggs) 106 | - [All Contributors](https://github.com/dominion-solutions/ansible-netbird/graphs/contributors) 107 | -------------------------------------------------------------------------------- /tests/unit/plugins/inventory/test_netbird.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright 2024 Dominion Solutions LLC (https://dominion.solutions) 3 | # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) 4 | 5 | from __future__ import (absolute_import, division, print_function) 6 | __metaclass__ = type 7 | 8 | import pytest 9 | 10 | from ansible.errors import AnsibleError 11 | from ansible.inventory.data import InventoryData 12 | from ansible.parsing.dataloader import DataLoader 13 | from ansible.template import Templar 14 | from ansible.utils.display import Display 15 | 16 | from ansible_collections.dominion_solutions.netbird.plugins.inventory.netbird import InventoryModule, NetbirdApi, Peer 17 | 18 | from unittest.mock import MagicMock 19 | import json 20 | 21 | display = Display() 22 | 23 | 24 | @pytest.fixture(scope="module") 25 | def inventory(): 26 | plugin = InventoryModule() 27 | plugin.templar = Templar(loader=DataLoader()) 28 | plugin._redirected_names = ["netbird", "dominion_solutions.netbird.netbird"] 29 | plugin._load_name = plugin.NAME 30 | return plugin 31 | 32 | 33 | @pytest.fixture(scope="module") 34 | def netbird_api(): 35 | mock_netbird_api = NetbirdApi(None, None) 36 | response_data = [] 37 | with open('tests/unit/module_utils/inventories/fixtures/peers.json') as peers_file: 38 | peers_map = json.load(peers_file) 39 | for data in peers_map: 40 | response_data.append(Peer(data['hostname'], data['dns_label'], data['id'], data)) 41 | 42 | mock_netbird_api.ListPeers = MagicMock(return_value=response_data) 43 | 44 | return mock_netbird_api 45 | 46 | 47 | @pytest.fixture(scope="module") 48 | def netbird_api_multigroup(): 49 | mock_netbird_api = NetbirdApi(None, None) 50 | response_data = [] 51 | with open('tests/unit/module_utils/inventories/fixtures/peers_multigroup.json') as peers_file: 52 | peers_map = json.load(peers_file) 53 | for data in peers_map: 54 | response_data.append(Peer(data['hostname'], data['dns_label'], data['id'], data)) 55 | 56 | mock_netbird_api.ListPeers = MagicMock(return_value=response_data) 57 | 58 | return mock_netbird_api 59 | 60 | 61 | @pytest.fixture(scope="module") 62 | def netbird_api_spaces_in_group(): 63 | mock_netbird_api = NetbirdApi(None, None) 64 | response_data = [] 65 | with open('tests/unit/module_utils/inventories/fixtures/peers_spaces_in_group.json') as peers_file: 66 | peers_map = json.load(peers_file) 67 | for data in peers_map: 68 | response_data.append(Peer(data['hostname'], data['dns_label'], data['id'], data)) 69 | 70 | mock_netbird_api.ListPeers = MagicMock(return_value=response_data) 71 | 72 | return mock_netbird_api 73 | 74 | 75 | def test_missing_access_token_lookup(inventory): 76 | loader = DataLoader() 77 | inventory._options = {'api_key': None, 'api_url': None} 78 | with pytest.raises(AnsibleError) as error_message: 79 | inventory._build_client(loader) 80 | assert 'Could not retrieve Netbird access token' in error_message 81 | 82 | 83 | def test_verify_file(tmp_path, inventory): 84 | file = tmp_path / "foobar.netbird.yml" 85 | file.touch() 86 | assert inventory.verify_file(str(file)) is True 87 | 88 | 89 | def test_verify_file_bad_config(inventory): 90 | assert inventory.verify_file('foobar.netbird.yml') is False 91 | 92 | 93 | def test_get_peer_data(inventory, netbird_api): 94 | loader = DataLoader() 95 | path = 'tests/unit/module_utils/inventories/fixtures/netbird.yml' 96 | inventory._build_client = MagicMock() 97 | inventory.client = netbird_api 98 | inventory.parse(InventoryData(), loader, path, False) 99 | assert inventory.inventory is not None 100 | assert inventory.inventory.hosts is not None 101 | assert len(inventory.inventory.groups.get('ssh_hosts').hosts) == 2 102 | assert len(inventory.inventory.groups.get('connected').hosts) == 1 103 | 104 | 105 | def test_get_only_connected_peers(inventory, netbird_api): 106 | loader = DataLoader() 107 | path = 'tests/unit/module_utils/inventories/fixtures/only_connected.netbird.yml' 108 | inventory._build_client = MagicMock() 109 | inventory.client = netbird_api 110 | inventory.parse(InventoryData(), loader, path, False) 111 | assert inventory.inventory is not None 112 | assert inventory.inventory.hosts is not None 113 | assert len(inventory.inventory.hosts) == 1 114 | assert list(inventory.inventory.hosts.values())[0].get_vars().get('connected') is True 115 | 116 | 117 | def test_with_multiple_groups(inventory, netbird_api_multigroup): 118 | loader = DataLoader() 119 | path = 'tests/unit/module_utils/inventories/fixtures/only_connected.netbird.yml' 120 | inventory._build_client = MagicMock() 121 | inventory.client = netbird_api_multigroup 122 | inventory.parse(InventoryData(), loader, path, False) 123 | assert inventory.inventory is not None 124 | assert inventory.inventory.hosts is not None 125 | assert inventory.inventory.groups is not None 126 | assert 'All' in inventory.inventory.groups 127 | assert 'Development' in inventory.inventory.groups 128 | 129 | 130 | def test_with_multiple_groups(inventory, netbird_api_multigroup): 131 | loader = DataLoader() 132 | path = 'tests/unit/module_utils/inventories/fixtures/only_connected.netbird.yml' 133 | inventory._build_client = MagicMock() 134 | inventory.client = netbird_api_multigroup 135 | inventory.parse(InventoryData(), loader, path, False) 136 | assert inventory.inventory is not None 137 | assert inventory.inventory.hosts is not None 138 | assert inventory.inventory.groups is not None 139 | assert 'All' in inventory.inventory.groups 140 | assert 'Development' in inventory.inventory.groups 141 | 142 | 143 | def test_use_ip_address(inventory, netbird_api_multigroup): 144 | loader = DataLoader() 145 | path = 'tests/unit/module_utils/inventories/fixtures/ip_address.netbird.yml' 146 | inventory._build_client = MagicMock() 147 | inventory.client = netbird_api_multigroup 148 | inventory.parse(InventoryData(), loader, path, False) 149 | assert inventory.inventory is not None 150 | assert inventory.inventory.hosts is not None 151 | assert inventory.inventory.groups is not None 152 | assert 'All' in inventory.inventory.groups 153 | assert 'Development' in inventory.inventory.groups 154 | 155 | 156 | def test_use_group_with_spaces(inventory, netbird_api_spaces_in_group): 157 | loader = DataLoader() 158 | path = 'tests/unit/module_utils/inventories/fixtures/spaces_in_group.netbird.yml' 159 | inventory._build_client = MagicMock() 160 | inventory.client = netbird_api_spaces_in_group 161 | inventory.parse(InventoryData(), loader, path, False) 162 | assert inventory.inventory is not None 163 | assert inventory.inventory.hosts is not None 164 | assert inventory.inventory.groups is not None 165 | assert 'All' in inventory.inventory.groups 166 | assert 'Test Group With Spaces' in inventory.inventory.groups 167 | -------------------------------------------------------------------------------- /plugins/inventory/netbird.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # netbird inventory Ansible plugin 3 | # Copyright: (c) 2024, Dominion Solutions LLC (https://dominion.solutions) 4 | # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import (absolute_import, division, print_function) 7 | __metaclass__ = type 8 | 9 | DOCUMENTATION = r''' 10 | name: netbird 11 | author: Mark J. Horninger (@spam-n-eggs) 12 | version_added: 0.0.2 13 | requirements: 14 | - requests>=2.31.0 15 | short_description: Get inventory from the Netbird API 16 | description: 17 | - Get inventory from the Netbird API. Allows for filtering based on Netbird Tags / Groups. 18 | extends_documentation_fragment: 19 | - constructed 20 | - inventory_cache 21 | options: 22 | cache: 23 | description: Cache plugin output to a file 24 | type: boolean 25 | default: true 26 | plugin: 27 | description: Marks this as an instance of the 'netbird' plugin. 28 | required: true 29 | choices: ['netbird', 'dominion_solutions.netbird.netbird'] 30 | ip_style: 31 | description: Populate hostvars with all information available from the Netbird API. 32 | type: string 33 | default: plain 34 | choices: 35 | - plain 36 | - api 37 | api_key: 38 | description: The API Key for the Netbird API. 39 | required: true 40 | type: string 41 | env: 42 | - name: NETBIRD_API_KEY 43 | api_url: 44 | description: The URL for the Netbird API. 45 | required: true 46 | type: string 47 | env: 48 | - name: NETBIRD_API_URL 49 | netbird_groups: 50 | description: A list of Netbird groups to filter the inventory by. 51 | type: list 52 | required: False 53 | elements: string 54 | netbird_connected: 55 | description: Filter the inventory by connected peers. 56 | default: True 57 | type: boolean 58 | strict: 59 | description: Whether or not to fail if a group or variable is not found. 60 | compose: 61 | description: compose variables for Ansible based on jinja2 expression and inventory vars 62 | required: False 63 | type: dict 64 | keyed_groups: 65 | description: create groups for plugins based on variable values and add the corresponding hosts to it 66 | type: list 67 | required: False 68 | ''' 69 | 70 | EXAMPLES = r""" 71 | # This is an inventory that finds the All Group and creates groups for the connected and ssh_enabled peers. 72 | --- 73 | plugin: dominion_solutions.netbird.netbird 74 | api_key: << api_key >> 75 | api_url: << api_url >> 76 | netbird_groups: 77 | - "All" 78 | groups: 79 | connected: connected 80 | ssh_hosts: ssh_enabled 81 | strict: No 82 | compose: 83 | ansible_ssh_host: label 84 | ansible_ssh_port: 22 85 | 86 | """ 87 | 88 | from ansible.errors import AnsibleError 89 | 90 | from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable 91 | from ansible.utils.display import Display 92 | 93 | # Specific for the NetbirdAPI Class 94 | import json 95 | 96 | try: 97 | import requests 98 | except ImportError: 99 | HAS_NETBIRD_API_LIBS = False 100 | else: 101 | HAS_NETBIRD_API_LIBS = True 102 | 103 | display = Display() 104 | 105 | 106 | class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): 107 | NAME = "dominion_solutions.netbird.netbird" 108 | 109 | def _cacheable_inventory(self): 110 | return [p._raw_json for p in self.peers] 111 | 112 | def _build_client(self, loader): 113 | """Build the Netbird API Client""" 114 | display.v("Building the Netbird API Client.") 115 | api_key = self.get_option('api_key') 116 | api_url = self.get_option('api_url') 117 | if self.templar.is_template(api_key): 118 | api_key = self.templar.template(api_key) 119 | if self.templar.is_template(api_url): 120 | api_url = self.templar.template(api_url) 121 | 122 | if api_key is None: 123 | raise AnsibleError("Could not retrieve the Netbird API Key from the configuration sources.") 124 | if api_url is None: 125 | raise AnsibleError("Could not retrieve the Netbird API URL from the configuration sources.") 126 | 127 | display.v(f"Set up the Netbird API Client with the URL: {api_url}") 128 | self.client = NetbirdApi(api_key, api_url) 129 | 130 | def _add_groups(self): 131 | """ Add peer groups to the inventory. """ 132 | self.netbird_groups = set( 133 | filter(None, [ 134 | group.get('name') for peer 135 | in self.peers 136 | for group in 137 | peer.data.get('groups') 138 | ])) 139 | for group in self.netbird_groups: 140 | self.inventory.add_group(group) 141 | 142 | def _add_peers_to_group(self): 143 | """ Add peers to the groups in the inventory. """ 144 | for peer in self.peers: 145 | for group in peer.data.get("groups"): 146 | self.inventory.add_host(peer.label, group=group.get('name')) 147 | 148 | def _get_peer_inventory(self): 149 | """Get the inventory from the Netbird API""" 150 | try: 151 | self.peers = self.client.ListPeers() 152 | except Exception: 153 | raise AnsibleError("Could not retrieve the Netbird inventory. Check the API Key and URL.") 154 | 155 | def _filter_by_config(self): 156 | """Filter peers by user specified configuration.""" 157 | connected = self.get_option('netbird_connected') 158 | groups = self.get_option('netbird_groups') 159 | if connected: 160 | self.peers = [ 161 | peer for peer in self.peers if peer.data.get('connected') 162 | ] 163 | if groups: 164 | self.peers = [ 165 | # 202410221 MJH: This list comprehension that filters the peers is a little hard to read. I'm sorry. 166 | # If you can fix it and make it more readable, please feel free to make a PR. 167 | peer for peer in self.peers 168 | if any( 169 | group 170 | in [ 171 | # Emulate a pluck here to grab the group names from the peer data. 172 | g.get('name') for g in peer.data.get('groups') 173 | ] 174 | for group in groups) 175 | ] 176 | 177 | def _add_hostvars_for_peers(self): 178 | """Add hostvars for peers in the dynamic inventory.""" 179 | ip_style = self.get_option('ip_style') 180 | for peer in self.peers: 181 | hostvars = peer._raw_json 182 | for hostvar_key in hostvars: 183 | if ip_style == 'api' and hostvar_key in ['ip', 'ipv6']: 184 | continue 185 | self.inventory.set_variable( 186 | peer.label, 187 | hostvar_key, 188 | hostvars[hostvar_key] 189 | ) 190 | if ip_style == 'api': 191 | ips = peer.ips.ipv4.public + peer.ips.ipv4.private 192 | ips += [peer.ips.ipv6.slaac, peer.ips.ipv6.link_local] 193 | ips += peer.ips.ipv6.pools 194 | 195 | for ip_type in set(ip.type for ip in ips): 196 | self.inventory.set_variable( 197 | peer.label, 198 | ip_type, 199 | self._ip_data([ip for ip in ips if ip.type == ip_type]) 200 | ) 201 | 202 | def verify_file(self, path): 203 | """Verify the Linode configuration file.""" 204 | if super(InventoryModule, self).verify_file(path): 205 | endings = ('netbird.yaml', 'netbird.yml') 206 | if any((path.endswith(ending) for ending in endings)): 207 | return True 208 | return False 209 | 210 | def parse(self, inventory, loader, path, cache=True): 211 | """Dynamically parse the inventory from the Netbird API""" 212 | super(InventoryModule, self).parse(inventory, loader, path) 213 | if not HAS_NETBIRD_API_LIBS: 214 | raise AnsibleError("the Netbird Dynamic inventory requires Requests.") 215 | 216 | self._options = self._read_config_data(path) 217 | self.peers = None 218 | 219 | cache_key = self.get_cache_key(path) 220 | 221 | if cache: 222 | cache = self.get_option('cache') 223 | update_cache = False 224 | if cache: 225 | try: 226 | self.peers = [Peer(None, i["id"], i) for i in self._cache[cache_key]] 227 | except KeyError: 228 | update_cache = True 229 | 230 | # Check for None rather than False in order to allow 231 | # for empty sets of cached peers 232 | if self.peers is None: 233 | self._build_client(loader) 234 | self._get_peer_inventory() 235 | 236 | if update_cache: 237 | self._cache[cache_key] = self._cacheable_inventory() 238 | 239 | self.populate() 240 | 241 | def populate(self): 242 | """ Populate the inventory with the peers from the Netbird API. """ 243 | strict = self.get_option('strict') 244 | 245 | self._filter_by_config() 246 | 247 | self._add_groups() 248 | self._add_peers_to_group() 249 | self._add_hostvars_for_peers() 250 | 251 | for peer in self.peers: 252 | variables = self.inventory.get_host(peer.label).get_vars() 253 | self._add_host_to_composed_groups( 254 | self.get_option('groups'), 255 | variables, 256 | peer.label, 257 | strict=strict) 258 | 259 | self._add_host_to_keyed_groups( 260 | self.get_option('keyed_groups'), 261 | variables, 262 | peer.label, 263 | strict=strict) 264 | 265 | self._set_composite_vars( 266 | self.get_option('compose'), 267 | variables, 268 | peer.label, 269 | strict=strict) 270 | 271 | 272 | # This is a very limited wrapper for the netbird API. 273 | class NetbirdApi: 274 | def __init__(self, api_key, api_url): 275 | self.api_key = api_key 276 | self.api_url = api_url 277 | 278 | def ListPeers(self): 279 | """List all peers in the Netbird API 280 | 281 | Returns: 282 | peers: A list of Peer objects with the data. 283 | """ 284 | url = f"{self.api_url}/peers" 285 | headers = { 286 | 'Accept': 'application/json', 287 | 'Authorization': f'Token {self.api_key}' 288 | } 289 | peers = [] 290 | response = requests.request("GET", url, headers=headers) 291 | if response.status_code in [401, 404]: 292 | raise Exception(f"{response.status_code}: {response.text}\nPlease check the API Key and URL.") 293 | 294 | peer_json = json.loads(response.text) 295 | for current_peer_map in peer_json: 296 | current_peer = Peer(current_peer_map["hostname"], current_peer_map['dns_label'], current_peer_map["id"], current_peer_map) 297 | peers.append(current_peer) 298 | return peers 299 | 300 | 301 | class Peer: 302 | # This is an example peers response from the Netbird API: 303 | # [ 304 | # { 305 | # "accessible_peers_count": 1, 306 | # "approval_required": false, 307 | # "connected": false, 308 | # "dns_label": "apple.netbird.cloud", 309 | # "groups": [ 310 | # { 311 | # "id": "2a3b4c5d6e7f8g9h0i1j", 312 | # "name": "All", 313 | # "peers_count": 2 314 | # } 315 | # ], 316 | # "hostname": "apple", 317 | # "id": "3a7b2c1d4e5f6g8h9i0j", 318 | # "ip": "100.0.0.42", 319 | # "last_login": "2024-02-10T22:01:27.744131502Z", 320 | # "last_seen": "2024-02-11T03:21:42.202104672Z", 321 | # "login_expiration_enabled": true, 322 | # "login_expired": false, 323 | # "name": "apple", 324 | # "os": "Linux Mint 21.3", 325 | # "ssh_enabled": false, 326 | # "ui_version": "netbird-desktop-ui/0.25.7", 327 | # "user_id": "auth0|ABC123xyz4567890", 328 | # "version": "0.25.7" 329 | # }, 330 | # { 331 | # "accessible_peers_count": 1, 332 | # "approval_required": false, 333 | # "connected": true, 334 | # "dns_label": "banana.netbird.cloud", 335 | # "groups": [ 336 | # { 337 | # "id": "2a3b4c5d6e7f8g9h0i1j", 338 | # "name": "All", 339 | # "peers_count": 2 340 | # } 341 | # ], 342 | # "hostname": "banana", 343 | # "id": "3a7b2c1d4e5f6g8h9i0j", 344 | # "ip": "100.0.0.61", 345 | # "last_login": "2024-02-02T11:20:05.934889112Z", 346 | # "last_seen": "2024-02-16T16:14:35.853243309Z", 347 | # "login_expiration_enabled": false, 348 | # "login_expired": false, 349 | # "name": "banana", 350 | # "os": "Alpine Linux 3.19.1", 351 | # "ssh_enabled": false, 352 | # "ui_version": "", 353 | # "user_id": "", 354 | # "version": "0.25.5" 355 | # } 356 | # ] 357 | @property 358 | def _raw_json(self): 359 | return self.data 360 | 361 | def __init__(self, name, label, id, data): 362 | self.name = name 363 | self.label = label 364 | self.id = id 365 | self.data = data 366 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Netbird Ansible Galaxy Collection - A collection of useful tools that interact with Netbird. 2 | Copyright (C) 2024 Dominion Solutions LLC 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | 17 | GNU GENERAL PUBLIC LICENSE 18 | Version 3, 29 June 2007 19 | 20 | Copyright (C) 2007 Free Software Foundation, Inc. 21 | Everyone is permitted to copy and distribute verbatim copies 22 | of this license document, but changing it is not allowed. 23 | 24 | Preamble 25 | 26 | The GNU General Public License is a free, copyleft license for 27 | software and other kinds of works. 28 | 29 | The licenses for most software and other practical works are designed 30 | to take away your freedom to share and change the works. By contrast, 31 | the GNU General Public License is intended to guarantee your freedom to 32 | share and change all versions of a program--to make sure it remains free 33 | software for all its users. We, the Free Software Foundation, use the 34 | GNU General Public License for most of our software; it applies also to 35 | any other work released this way by its authors. You can apply it to 36 | your programs, too. 37 | 38 | When we speak of free software, we are referring to freedom, not 39 | price. Our General Public Licenses are designed to make sure that you 40 | have the freedom to distribute copies of free software (and charge for 41 | them if you wish), that you receive source code or can get it if you 42 | want it, that you can change the software or use pieces of it in new 43 | free programs, and that you know you can do these things. 44 | 45 | To protect your rights, we need to prevent others from denying you 46 | these rights or asking you to surrender the rights. Therefore, you have 47 | certain responsibilities if you distribute copies of the software, or if 48 | you modify it: responsibilities to respect the freedom of others. 49 | 50 | For example, if you distribute copies of such a program, whether 51 | gratis or for a fee, you must pass on to the recipients the same 52 | freedoms that you received. You must make sure that they, too, receive 53 | or can get the source code. And you must show them these terms so they 54 | know their rights. 55 | 56 | Developers that use the GNU GPL protect your rights with two steps: 57 | (1) assert copyright on the software, and (2) offer you this License 58 | giving you legal permission to copy, distribute and/or modify it. 59 | 60 | For the developers' and authors' protection, the GPL clearly explains 61 | that there is no warranty for this free software. For both users' and 62 | authors' sake, the GPL requires that modified versions be marked as 63 | changed, so that their problems will not be attributed erroneously to 64 | authors of previous versions. 65 | 66 | Some devices are designed to deny users access to install or run 67 | modified versions of the software inside them, although the manufacturer 68 | can do so. This is fundamentally incompatible with the aim of 69 | protecting users' freedom to change the software. The systematic 70 | pattern of such abuse occurs in the area of products for individuals to 71 | use, which is precisely where it is most unacceptable. Therefore, we 72 | have designed this version of the GPL to prohibit the practice for those 73 | products. If such problems arise substantially in other domains, we 74 | stand ready to extend this provision to those domains in future versions 75 | of the GPL, as needed to protect the freedom of users. 76 | 77 | Finally, every program is threatened constantly by software patents. 78 | States should not allow patents to restrict development and use of 79 | software on general-purpose computers, but in those that do, we wish to 80 | avoid the special danger that patents applied to a free program could 81 | make it effectively proprietary. To prevent this, the GPL assures that 82 | patents cannot be used to render the program non-free. 83 | 84 | The precise terms and conditions for copying, distribution and 85 | modification follow. 86 | 87 | TERMS AND CONDITIONS 88 | 89 | 1. Definitions. 90 | 91 | "This License" refers to version 3 of the GNU General Public License. 92 | 93 | "Copyright" also means copyright-like laws that apply to other kinds of 94 | works, such as semiconductor masks. 95 | 96 | "The Program" refers to any copyrightable work licensed under this 97 | License. Each licensee is addressed as "you". "Licensees" and 98 | "recipients" may be individuals or organizations. 99 | 100 | To "modify" a work means to copy from or adapt all or part of the work 101 | in a fashion requiring copyright permission, other than the making of an 102 | exact copy. The resulting work is called a "modified version" of the 103 | earlier work or a work "based on" the earlier work. 104 | 105 | A "covered work" means either the unmodified Program or a work based 106 | on the Program. 107 | 108 | To "propagate" a work means to do anything with it that, without 109 | permission, would make you directly or secondarily liable for 110 | infringement under applicable copyright law, except executing it on a 111 | computer or modifying a private copy. Propagation includes copying, 112 | distribution (with or without modification), making available to the 113 | public, and in some countries other activities as well. 114 | 115 | To "convey" a work means any kind of propagation that enables other 116 | parties to make or receive copies. Mere interaction with a user through 117 | a computer network, with no transfer of a copy, is not conveying. 118 | 119 | An interactive user interface displays "Appropriate Legal Notices" 120 | to the extent that it includes a convenient and prominently visible 121 | feature that (1) displays an appropriate copyright notice, and (2) 122 | tells the user that there is no warranty for the work (except to the 123 | extent that warranties are provided), that licensees may convey the 124 | work under this License, and how to view a copy of this License. If 125 | the interface presents a list of user commands or options, such as a 126 | menu, a prominent item in the list meets this criterion. 127 | 128 | 1. Source Code. 129 | 130 | The "source code" for a work means the preferred form of the work 131 | for making modifications to it. "Object code" means any non-source 132 | form of a work. 133 | 134 | A "Standard Interface" means an interface that either is an official 135 | standard defined by a recognized standards body, or, in the case of 136 | interfaces specified for a particular programming language, one that 137 | is widely used among developers working in that language. 138 | 139 | The "System Libraries" of an executable work include anything, other 140 | than the work as a whole, that (a) is included in the normal form of 141 | packaging a Major Component, but which is not part of that Major 142 | Component, and (b) serves only to enable use of the work with that 143 | Major Component, or to implement a Standard Interface for which an 144 | implementation is available to the public in source code form. A 145 | "Major Component", in this context, means a major essential component 146 | (kernel, window system, and so on) of the specific operating system 147 | (if any) on which the executable work runs, or a compiler used to 148 | produce the work, or an object code interpreter used to run it. 149 | 150 | The "Corresponding Source" for a work in object code form means all 151 | the source code needed to generate, install, and (for an executable 152 | work) run the object code and to modify the work, including scripts to 153 | control those activities. However, it does not include the work's 154 | System Libraries, or general-purpose tools or generally available free 155 | programs which are used unmodified in performing those activities but 156 | which are not part of the work. For example, Corresponding Source 157 | includes interface definition files associated with source files for 158 | the work, and the source code for shared libraries and dynamically 159 | linked subprograms that the work is specifically designed to require, 160 | such as by intimate data communication or control flow between those 161 | subprograms and other parts of the work. 162 | 163 | The Corresponding Source need not include anything that users 164 | can regenerate automatically from other parts of the Corresponding 165 | Source. 166 | 167 | The Corresponding Source for a work in source code form is that 168 | same work. 169 | 170 | 2. Basic Permissions. 171 | 172 | All rights granted under this License are granted for the term of 173 | copyright on the Program, and are irrevocable provided the stated 174 | conditions are met. This License explicitly affirms your unlimited 175 | permission to run the unmodified Program. The output from running a 176 | covered work is covered by this License only if the output, given its 177 | content, constitutes a covered work. This License acknowledges your 178 | rights of fair use or other equivalent, as provided by copyright law. 179 | 180 | You may make, run and propagate covered works that you do not 181 | convey, without conditions so long as your license otherwise remains 182 | in force. You may convey covered works to others for the sole purpose 183 | of having them make modifications exclusively for you, or provide you 184 | with facilities for running those works, provided that you comply with 185 | the terms of this License in conveying all material for which you do 186 | not control copyright. Those thus making or running the covered works 187 | for you must do so exclusively on your behalf, under your direction 188 | and control, on terms that prohibit them from making any copies of 189 | your copyrighted material outside their relationship with you. 190 | 191 | Conveying under any other circumstances is permitted solely under 192 | the conditions stated below. Sublicensing is not allowed; section 10 193 | makes it unnecessary. 194 | 195 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 196 | 197 | No covered work shall be deemed part of an effective technological 198 | measure under any applicable law fulfilling obligations under article 199 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 200 | similar laws prohibiting or restricting circumvention of such 201 | measures. 202 | 203 | When you convey a covered work, you waive any legal power to forbid 204 | circumvention of technological measures to the extent such circumvention 205 | is effected by exercising rights under this License with respect to 206 | the covered work, and you disclaim any intention to limit operation or 207 | modification of the work as a means of enforcing, against the work's 208 | users, your or third parties' legal rights to forbid circumvention of 209 | technological measures. 210 | 211 | 4. Conveying Verbatim Copies. 212 | 213 | You may convey verbatim copies of the Program's source code as you 214 | receive it, in any medium, provided that you conspicuously and 215 | appropriately publish on each copy an appropriate copyright notice; 216 | keep intact all notices stating that this License and any 217 | non-permissive terms added in accord with section 7 apply to the code; 218 | keep intact all notices of the absence of any warranty; and give all 219 | recipients a copy of this License along with the Program. 220 | 221 | You may charge any price or no price for each copy that you convey, 222 | and you may offer support or warranty protection for a fee. 223 | 224 | 5. Conveying Modified Source Versions. 225 | 226 | You may convey a work based on the Program, or the modifications to 227 | produce it from the Program, in the form of source code under the 228 | terms of section 4, provided that you also meet all of these conditions: 229 | 230 | a) The work must carry prominent notices stating that you modified 231 | it, and giving a relevant date. 232 | 233 | b) The work must carry prominent notices stating that it is 234 | released under this License and any conditions added under section 235 | 7. This requirement modifies the requirement in section 4 to 236 | "keep intact all notices". 237 | 238 | c) You must license the entire work, as a whole, under this 239 | License to anyone who comes into possession of a copy. This 240 | License will therefore apply, along with any applicable section 7 241 | additional terms, to the whole of the work, and all its parts, 242 | regardless of how they are packaged. This License gives no 243 | permission to license the work in any other way, but it does not 244 | invalidate such permission if you have separately received it. 245 | 246 | d) If the work has interactive user interfaces, each must display 247 | Appropriate Legal Notices; however, if the Program has interactive 248 | interfaces that do not display Appropriate Legal Notices, your 249 | work need not make them do so. 250 | 251 | A compilation of a covered work with other separate and independent 252 | works, which are not by their nature extensions of the covered work, 253 | and which are not combined with it such as to form a larger program, 254 | in or on a volume of a storage or distribution medium, is called an 255 | "aggregate" if the compilation and its resulting copyright are not 256 | used to limit the access or legal rights of the compilation's users 257 | beyond what the individual works permit. Inclusion of a covered work 258 | in an aggregate does not cause this License to apply to the other 259 | parts of the aggregate. 260 | 261 | 6. Conveying Non-Source Forms. 262 | 263 | You may convey a covered work in object code form under the terms 264 | of sections 4 and 5, provided that you also convey the 265 | machine-readable Corresponding Source under the terms of this License, 266 | in one of these ways: 267 | 268 | a) Convey the object code in, or embodied in, a physical product 269 | (including a physical distribution medium), accompanied by the 270 | Corresponding Source fixed on a durable physical medium 271 | customarily used for software interchange. 272 | 273 | b) Convey the object code in, or embodied in, a physical product 274 | (including a physical distribution medium), accompanied by a 275 | written offer, valid for at least three years and valid for as 276 | long as you offer spare parts or customer support for that product 277 | model, to give anyone who possesses the object code either (1) a 278 | copy of the Corresponding Source for all the software in the 279 | product that is covered by this License, on a durable physical 280 | medium customarily used for software interchange, for a price no 281 | more than your reasonable cost of physically performing this 282 | conveying of source, or (2) access to copy the 283 | Corresponding Source from a network server at no charge. 284 | 285 | c) Convey individual copies of the object code with a copy of the 286 | written offer to provide the Corresponding Source. This 287 | alternative is allowed only occasionally and noncommercially, and 288 | only if you received the object code with such an offer, in accord 289 | with subsection 6b. 290 | 291 | d) Convey the object code by offering access from a designated 292 | place (gratis or for a charge), and offer equivalent access to the 293 | Corresponding Source in the same way through the same place at no 294 | further charge. You need not require recipients to copy the 295 | Corresponding Source along with the object code. If the place to 296 | copy the object code is a network server, the Corresponding Source 297 | may be on a different server (operated by you or a third party) 298 | that supports equivalent copying facilities, provided you maintain 299 | clear directions next to the object code saying where to find the 300 | Corresponding Source. Regardless of what server hosts the 301 | Corresponding Source, you remain obligated to ensure that it is 302 | available for as long as needed to satisfy these requirements. 303 | 304 | e) Convey the object code using peer-to-peer transmission, provided 305 | you inform other peers where the object code and Corresponding 306 | Source of the work are being offered to the general public at no 307 | charge under subsection 6d. 308 | 309 | A separable portion of the object code, whose source code is excluded 310 | from the Corresponding Source as a System Library, need not be 311 | included in conveying the object code work. 312 | 313 | A "User Product" is either (1) a "consumer product", which means any 314 | tangible personal property which is normally used for personal, family, 315 | or household purposes, or (2) anything designed or sold for incorporation 316 | into a dwelling. In determining whether a product is a consumer product, 317 | doubtful cases shall be resolved in favor of coverage. For a particular 318 | product received by a particular user, "normally used" refers to a 319 | typical or common use of that class of product, regardless of the status 320 | of the particular user or of the way in which the particular user 321 | actually uses, or expects or is expected to use, the product. A product 322 | is a consumer product regardless of whether the product has substantial 323 | commercial, industrial or non-consumer uses, unless such uses represent 324 | the only significant mode of use of the product. 325 | 326 | "Installation Information" for a User Product means any methods, 327 | procedures, authorization keys, or other information required to install 328 | and execute modified versions of a covered work in that User Product from 329 | a modified version of its Corresponding Source. The information must 330 | suffice to ensure that the continued functioning of the modified object 331 | code is in no case prevented or interfered with solely because 332 | modification has been made. 333 | 334 | If you convey an object code work under this section in, or with, or 335 | specifically for use in, a User Product, and the conveying occurs as 336 | part of a transaction in which the right of possession and use of the 337 | User Product is transferred to the recipient in perpetuity or for a 338 | fixed term (regardless of how the transaction is characterized), the 339 | Corresponding Source conveyed under this section must be accompanied 340 | by the Installation Information. But this requirement does not apply 341 | if neither you nor any third party retains the ability to install 342 | modified object code on the User Product (for example, the work has 343 | been installed in ROM). 344 | 345 | The requirement to provide Installation Information does not include a 346 | requirement to continue to provide support service, warranty, or updates 347 | for a work that has been modified or installed by the recipient, or for 348 | the User Product in which it has been modified or installed. Access to a 349 | network may be denied when the modification itself materially and 350 | adversely affects the operation of the network or violates the rules and 351 | protocols for communication across the network. 352 | 353 | Corresponding Source conveyed, and Installation Information provided, 354 | in accord with this section must be in a format that is publicly 355 | documented (and with an implementation available to the public in 356 | source code form), and must require no special password or key for 357 | unpacking, reading or copying. 358 | 359 | 7. Additional Terms. 360 | 361 | "Additional permissions" are terms that supplement the terms of this 362 | License by making exceptions from one or more of its conditions. 363 | Additional permissions that are applicable to the entire Program shall 364 | be treated as though they were included in this License, to the extent 365 | that they are valid under applicable law. If additional permissions 366 | apply only to part of the Program, that part may be used separately 367 | under those permissions, but the entire Program remains governed by 368 | this License without regard to the additional permissions. 369 | 370 | When you convey a copy of a covered work, you may at your option 371 | remove any additional permissions from that copy, or from any part of 372 | it. (Additional permissions may be written to require their own 373 | removal in certain cases when you modify the work.) You may place 374 | additional permissions on material, added by you to a covered work, 375 | for which you have or can give appropriate copyright permission. 376 | 377 | Notwithstanding any other provision of this License, for material you 378 | add to a covered work, you may (if authorized by the copyright holders of 379 | that material) supplement the terms of this License with terms: 380 | 381 | a) Disclaiming warranty or limiting liability differently from the 382 | terms of sections 15 and 16 of this License; or 383 | 384 | b) Requiring preservation of specified reasonable legal notices or 385 | author attributions in that material or in the Appropriate Legal 386 | Notices displayed by works containing it; or 387 | 388 | c) Prohibiting misrepresentation of the origin of that material, or 389 | requiring that modified versions of such material be marked in 390 | reasonable ways as different from the original version; or 391 | 392 | d) Limiting the use for publicity purposes of names of licensors or 393 | authors of the material; or 394 | 395 | e) Declining to grant rights under trademark law for use of some 396 | trade names, trademarks, or service marks; or 397 | 398 | f) Requiring indemnification of licensors and authors of that 399 | material by anyone who conveys the material (or modified versions of 400 | it) with contractual assumptions of liability to the recipient, for 401 | any liability that these contractual assumptions directly impose on 402 | those licensors and authors. 403 | 404 | All other non-permissive additional terms are considered "further 405 | restrictions" within the meaning of section 10. If the Program as you 406 | received it, or any part of it, contains a notice stating that it is 407 | governed by this License along with a term that is a further 408 | restriction, you may remove that term. If a license document contains 409 | a further restriction but permits relicensing or conveying under this 410 | License, you may add to a covered work material governed by the terms 411 | of that license document, provided that the further restriction does 412 | not survive such relicensing or conveying. 413 | 414 | If you add terms to a covered work in accord with this section, you 415 | must place, in the relevant source files, a statement of the 416 | additional terms that apply to those files, or a notice indicating 417 | where to find the applicable terms. 418 | 419 | Additional terms, permissive or non-permissive, may be stated in the 420 | form of a separately written license, or stated as exceptions; 421 | the above requirements apply either way. 422 | 423 | 8. Termination. 424 | 425 | You may not propagate or modify a covered work except as expressly 426 | provided under this License. Any attempt otherwise to propagate or 427 | modify it is void, and will automatically terminate your rights under 428 | this License (including any patent licenses granted under the third 429 | paragraph of section 11). 430 | 431 | However, if you cease all violation of this License, then your 432 | license from a particular copyright holder is reinstated (a) 433 | provisionally, unless and until the copyright holder explicitly and 434 | finally terminates your license, and (b) permanently, if the copyright 435 | holder fails to notify you of the violation by some reasonable means 436 | prior to 60 days after the cessation. 437 | 438 | Moreover, your license from a particular copyright holder is 439 | reinstated permanently if the copyright holder notifies you of the 440 | violation by some reasonable means, this is the first time you have 441 | received notice of violation of this License (for any work) from that 442 | copyright holder, and you cure the violation prior to 30 days after 443 | your receipt of the notice. 444 | 445 | Termination of your rights under this section does not terminate the 446 | licenses of parties who have received copies or rights from you under 447 | this License. If your rights have been terminated and not permanently 448 | reinstated, you do not qualify to receive new licenses for the same 449 | material under section 10. 450 | 451 | 9. Acceptance Not Required for Having Copies. 452 | 453 | You are not required to accept this License in order to receive or 454 | run a copy of the Program. Ancillary propagation of a covered work 455 | occurring solely as a consequence of using peer-to-peer transmission 456 | to receive a copy likewise does not require acceptance. However, 457 | nothing other than this License grants you permission to propagate or 458 | modify any covered work. These actions infringe copyright if you do 459 | not accept this License. Therefore, by modifying or propagating a 460 | covered work, you indicate your acceptance of this License to do so. 461 | 462 | 10. Automatic Licensing of Downstream Recipients. 463 | 464 | Each time you convey a covered work, the recipient automatically 465 | receives a license from the original licensors, to run, modify and 466 | propagate that work, subject to this License. You are not responsible 467 | for enforcing compliance by third parties with this License. 468 | 469 | An "entity transaction" is a transaction transferring control of an 470 | organization, or substantially all assets of one, or subdividing an 471 | organization, or merging organizations. If propagation of a covered 472 | work results from an entity transaction, each party to that 473 | transaction who receives a copy of the work also receives whatever 474 | licenses to the work the party's predecessor in interest had or could 475 | give under the previous paragraph, plus a right to possession of the 476 | Corresponding Source of the work from the predecessor in interest, if 477 | the predecessor has it or can get it with reasonable efforts. 478 | 479 | You may not impose any further restrictions on the exercise of the 480 | rights granted or affirmed under this License. For example, you may 481 | not impose a license fee, royalty, or other charge for exercise of 482 | rights granted under this License, and you may not initiate litigation 483 | (including a cross-claim or counterclaim in a lawsuit) alleging that 484 | any patent claim is infringed by making, using, selling, offering for 485 | sale, or importing the Program or any portion of it. 486 | 487 | 11. Patents. 488 | 489 | A "contributor" is a copyright holder who authorizes use under this 490 | License of the Program or a work on which the Program is based. The 491 | work thus licensed is called the contributor's "contributor version". 492 | 493 | A contributor's "essential patent claims" are all patent claims 494 | owned or controlled by the contributor, whether already acquired or 495 | hereafter acquired, that would be infringed by some manner, permitted 496 | by this License, of making, using, or selling its contributor version, 497 | but do not include claims that would be infringed only as a 498 | consequence of further modification of the contributor version. For 499 | purposes of this definition, "control" includes the right to grant 500 | patent sublicenses in a manner consistent with the requirements of 501 | this License. 502 | 503 | Each contributor grants you a non-exclusive, worldwide, royalty-free 504 | patent license under the contributor's essential patent claims, to 505 | make, use, sell, offer for sale, import and otherwise run, modify and 506 | propagate the contents of its contributor version. 507 | 508 | In the following three paragraphs, a "patent license" is any express 509 | agreement or commitment, however denominated, not to enforce a patent 510 | (such as an express permission to practice a patent or covenant not to 511 | sue for patent infringement). To "grant" such a patent license to a 512 | party means to make such an agreement or commitment not to enforce a 513 | patent against the party. 514 | 515 | If you convey a covered work, knowingly relying on a patent license, 516 | and the Corresponding Source of the work is not available for anyone 517 | to copy, free of charge and under the terms of this License, through a 518 | publicly available network server or other readily accessible means, 519 | then you must either (1) cause the Corresponding Source to be so 520 | available, or (2) arrange to deprive yourself of the benefit of the 521 | patent license for this particular work, or (3) arrange, in a manner 522 | consistent with the requirements of this License, to extend the patent 523 | license to downstream recipients. "Knowingly relying" means you have 524 | actual knowledge that, but for the patent license, your conveying the 525 | covered work in a country, or your recipient's use of the covered work 526 | in a country, would infringe one or more identifiable patents in that 527 | country that you have reason to believe are valid. 528 | 529 | If, pursuant to or in connection with a single transaction or 530 | arrangement, you convey, or propagate by procuring conveyance of, a 531 | covered work, and grant a patent license to some of the parties 532 | receiving the covered work authorizing them to use, propagate, modify 533 | or convey a specific copy of the covered work, then the patent license 534 | you grant is automatically extended to all recipients of the covered 535 | work and works based on it. 536 | 537 | A patent license is "discriminatory" if it does not include within 538 | the scope of its coverage, prohibits the exercise of, or is 539 | conditioned on the non-exercise of one or more of the rights that are 540 | specifically granted under this License. You may not convey a covered 541 | work if you are a party to an arrangement with a third party that is 542 | in the business of distributing software, under which you make payment 543 | to the third party based on the extent of your activity of conveying 544 | the work, and under which the third party grants, to any of the 545 | parties who would receive the covered work from you, a discriminatory 546 | patent license (a) in connection with copies of the covered work 547 | conveyed by you (or copies made from those copies), or (b) primarily 548 | for and in connection with specific products or compilations that 549 | contain the covered work, unless you entered into that arrangement, 550 | or that patent license was granted, prior to 28 March 2007. 551 | 552 | Nothing in this License shall be construed as excluding or limiting 553 | any implied license or other defenses to infringement that may 554 | otherwise be available to you under applicable patent law. 555 | 556 | 12. No Surrender of Others' Freedom. 557 | 558 | If conditions are imposed on you (whether by court order, agreement or 559 | otherwise) that contradict the conditions of this License, they do not 560 | excuse you from the conditions of this License. If you cannot convey a 561 | covered work so as to satisfy simultaneously your obligations under this 562 | License and any other pertinent obligations, then as a consequence you may 563 | not convey it at all. For example, if you agree to terms that obligate you 564 | to collect a royalty for further conveying from those to whom you convey 565 | the Program, the only way you could satisfy both those terms and this 566 | License would be to refrain entirely from conveying the Program. 567 | 568 | 13. Use with the GNU Affero General Public License. 569 | 570 | Notwithstanding any other provision of this License, you have 571 | permission to link or combine any covered work with a work licensed 572 | under version 3 of the GNU Affero General Public License into a single 573 | combined work, and to convey the resulting work. The terms of this 574 | License will continue to apply to the part which is the covered work, 575 | but the special requirements of the GNU Affero General Public License, 576 | section 13, concerning interaction through a network will apply to the 577 | combination as such. 578 | 579 | 14. Revised Versions of this License. 580 | 581 | The Free Software Foundation may publish revised and/or new versions of 582 | the GNU General Public License from time to time. Such new versions will 583 | be similar in spirit to the present version, but may differ in detail to 584 | address new problems or concerns. 585 | 586 | Each version is given a distinguishing version number. If the 587 | Program specifies that a certain numbered version of the GNU General 588 | Public License "or any later version" applies to it, you have the 589 | option of following the terms and conditions either of that numbered 590 | version or of any later version published by the Free Software 591 | Foundation. If the Program does not specify a version number of the 592 | GNU General Public License, you may choose any version ever published 593 | by the Free Software Foundation. 594 | 595 | If the Program specifies that a proxy can decide which future 596 | versions of the GNU General Public License can be used, that proxy's 597 | public statement of acceptance of a version permanently authorizes you 598 | to choose that version for the Program. 599 | 600 | Later license versions may give you additional or different 601 | permissions. However, no additional obligations are imposed on any 602 | author or copyright holder as a result of your choosing to follow a 603 | later version. 604 | 605 | 15. Disclaimer of Warranty. 606 | 607 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 608 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 609 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 610 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 611 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 612 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 613 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 614 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 615 | 616 | 16. Limitation of Liability. 617 | 618 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 619 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 620 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 621 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 622 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 623 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 624 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 625 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 626 | SUCH DAMAGES. 627 | 628 | 17. Interpretation of Sections 15 and 16. 629 | 630 | If the disclaimer of warranty and limitation of liability provided 631 | above cannot be given local legal effect according to their terms, 632 | reviewing courts shall apply local law that most closely approximates 633 | an absolute waiver of all civil liability in connection with the 634 | Program, unless a warranty or assumption of liability accompanies a 635 | copy of the Program in return for a fee. 636 | 637 | END OF TERMS AND CONDITIONS 638 | 639 | How to Apply These Terms to Your New Programs 640 | 641 | If you develop a new program, and you want it to be of the greatest 642 | possible use to the public, the best way to achieve this is to make it 643 | free software which everyone can redistribute and change under these terms. 644 | 645 | To do so, attach the following notices to the program. It is safest 646 | to attach them to the start of each source file to most effectively 647 | state the exclusion of warranty; and each file should have at least 648 | the "copyright" line and a pointer to where the full notice is found. 649 | 650 | 651 | Copyright (C) 652 | 653 | This program is free software: you can redistribute it and/or modify 654 | it under the terms of the GNU General Public License as published by 655 | the Free Software Foundation, either version 3 of the License, or 656 | (at your option) any later version. 657 | 658 | This program is distributed in the hope that it will be useful, 659 | but WITHOUT ANY WARRANTY; without even the implied warranty of 660 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 661 | GNU General Public License for more details. 662 | 663 | You should have received a copy of the GNU General Public License 664 | along with this program. If not, see . 665 | 666 | Also add information on how to contact you by electronic and paper mail. 667 | 668 | If the program does terminal interaction, make it output a short 669 | notice like this when it starts in an interactive mode: 670 | 671 | Copyright (C) 672 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 673 | This is free software, and you are welcome to redistribute it 674 | under certain conditions; type `show c' for details. 675 | 676 | The hypothetical commands `show w' and `show c' should show the appropriate 677 | parts of the General Public License. Of course, your program's commands 678 | might be different; for a GUI interface, you would use an "about box". 679 | 680 | You should also get your employer (if you work as a programmer) or school, 681 | if any, to sign a "copyright disclaimer" for the program, if necessary. 682 | For more information on this, and how to apply and follow the GNU GPL, see 683 | . 684 | 685 | The GNU General Public License does not permit incorporating your program 686 | into proprietary programs. If your program is a subroutine library, you 687 | may consider it more useful to permit linking proprietary applications with 688 | the library. If this is what you want to do, use the GNU Lesser General 689 | Public License instead of this License. But first, please read 690 | . 691 | --------------------------------------------------------------------------------