Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sananguliyev committed Jan 28, 2020
2 parents 8feef70 + 84a1ff6 commit 7259a4b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 11 deletions.
80 changes: 74 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
[![PyPI](https://img.shields.io/pypi/v/ansible-filter)](https://pypi.org/project/ansible-filter/#history)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/ansible-filter)](https://pypi.org/project/ansible-filter/#files)

# Ansible Filter Hetzner
# Ansible Filter

Filter plugin set to interact with the [Hetzer Robot API](https://robot.your-server.de/doc/webservice/en.html) using [Ansible](https://www.ansible.com/).
Following functionality is provided:
- Compute the resource change set between local and origin state.
- URL encode request body
- Filter dictionary by key
Contains [Ansible](https://www.ansible.com/) related filter set for collection/object operations. Aims to extend the official
[Ansible Filters](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html).

Available filters are listed [below](#filters).

## Install

Expand Down Expand Up @@ -121,6 +120,75 @@ Converts a list to dict by key attribute.

{'1': {'foo': 'bar', 'id': '1'}, '2': {'id': '2', 'foz': 'baz'}}

### Point to Point Connections
Resolves point to point connections between the local and remote hosts.

from ansible_filter import network

remote_hostnames = ['two', 'three']
hostname = 'one'
hostvars = {
'one': {
'ansible_default_ipv4': {
'interface': 'eth0'
},
'ansible_eth0': {
'ipv4': {
'address': '127.0.0.1',
}
}
},
'two': {
'ansible_default_ipv4': {
'interface': 'eth0'
},
'ansible_eth0': {
'ipv4': {
'address': '127.0.0.2',
}
}
},
'three': {
'ansible_default_ipv4': {
'interface': 'eth0'
},
'ansible_eth0': {
'ipv4': {
'address': '127.0.0.3',
}
}
}
}

result = network.get_point_to_point_connections(remote_hostnames, hostname, hostvars)

[
{
'remote': {
'interface': 'eth0',
'hostname': 'two',
'address': '127.0.0.2'
},
'local': {
'interface': 'eth0',
'hostname': 'one',
'address': '127.0.0.1'
}
},
{
'remote': {
'interface': 'eth0',
'hostname': 'three',
'address': '127.0.0.3'
},
'local': {
'interface': 'eth0',
'hostname': 'one',
'address': '127.0.0.1'
}
}
]

## Links

* Website: https://newsletter2go.com/
Expand Down
4 changes: 2 additions & 2 deletions ansible_filter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .helpers import array_to_dict as list_to_dict
from . import omit
from . import pick
from . import network_encryption
from . import network


__version__ = "1.0"
__version__ = "1.0.0"
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/python
from ansible_filter.helpers import array_to_dict


def get_custom_interface_name_or_default(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest

from ansible_filter.network_encryption import *
from ansible_filter.network import *


class NetworkEncryptionTest(unittest.TestCase):
class NetworkTest(unittest.TestCase):
def test_single(self):
local_hostname = "local_hostname"
remote_hostname = local_hostname
Expand Down

0 comments on commit 7259a4b

Please sign in to comment.