Skip to content

Instantly share code, notes, and snippets.

@kikyous
Last active December 7, 2022 05:45
Show Gist options
  • Save kikyous/b62357d250a075818b2b4e2a11eec372 to your computer and use it in GitHub Desktop.
Save kikyous/b62357d250a075818b2b4e2a11eec372 to your computer and use it in GitHub Desktop.
open-tc-mysql
---
- hosts: tc-swarm-cluster
gather_facts: no
run_once: True
tasks:
- name: open database client
delegate_to: 127.0.0.1
ansible.builtin.shell: "open 'mysql://{{db_user}}:{{db_password}}@127.0.0.1:63306/{{ db_name }}'"
register: mysql
tags: mysql
- name: ssh tunnel
delegate_to: 127.0.0.1
ansible.builtin.shell: "ssh -F inventories/{{inventory_dir.split('/')[-1]}}/ssh-config -L 63306:{{db_host}}:{{db_port}} {{inventory_hostname}} -N"
register: ssh
tags: ssh
- name: echo ssh result
delegate_to: 127.0.0.1
ansible.builtin.debug:
var: ssh
- name: echo mysql result
delegate_to: 127.0.0.1
ansible.builtin.debug:
var: mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment