ansible-mysql/tasks/replication/slave/ssh.yml

20 lines
542 B
YAML

---
- name: SHELL | Create SSH key if needed on slave
shell: "ssh-keygen -b 2048 -t rsa -f {{ ansible_env.HOME }}/.ssh/id_rsa -q -N ''"
args:
creates: "{{ ansible_env.HOME }}/.ssh/id_rsa"
- name: COMMAND | Get pub key
command: cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub
register: pub_key
changed_when: false
- name: AUTHORIZED_KEY | Auth slave to backup host
authorized_key:
user: "{{ mysql_backup_user }}"
state: present
key: "{{ pub_key.stdout }}"
delegate_to: "{{ mysql_slave_import_from }}"
become: yes