Skip to content

How to put the iptables issues into the playbook? #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
agstephens opened this issue Sep 18, 2020 · 2 comments
Open

How to put the iptables issues into the playbook? #57

agstephens opened this issue Sep 18, 2020 · 2 comments

Comments

@agstephens
Copy link
Contributor

agstephens commented Sep 18, 2020

We, and others using our playbooks, will be confused if the services are failing after the playbook has succeeded.

We need to include a check or some flag for the deployer to set that will explain the ports issue.

E.g.:

check_ports_are_open = true

This would at least bring the issue to the attention of the deployer.

We should document it clearly in the READMEs as well.

@agstephens
Copy link
Contributor Author

Could upload and run this script, or similar:

# test-connections.py

import socket

required = {
    'wps1': [80, 5432, 6817],
    'batch1': [6818],
    'batch2': [6818],
    'batch3': [6818],
}

def test_connection(host, port):
    a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    socket.setdefaulttimeout(3)

    location = (host, port)
    result_of_check = a_socket.connect_ex(location)

    print(f'Testing: {location}', end=' --> ')
    if result_of_check == 0:
        print("Port is open")
    else:
        print("Port is not open")

    a_socket.close()


def test_all():
    for host, ports in required.items():
        host = f'test-{host}'

        for port in ports:
            test_connection(host, port)


if __name__ == '__main__':

    test_all()

@cehbrecht
Copy link
Collaborator

We can use netcat:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html

There is a playbook for this task:
https://ryandaniels.ca/blog/ansible-role-test-network-connectivity/

... but executed on the ansible host ... are ports open to the ansible host?

We could use post_tasks and delegate_to to run task on specific node:
https://docs.ansible.com/ansible/latest/reference_appendices/test_strategies.html#integrating-testing-with-rolling-updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants