Last active
December 7, 2022 05:45
-
-
Save kikyous/b62357d250a075818b2b4e2a11eec372 to your computer and use it in GitHub Desktop.
open-tc-mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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