Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

SSH Port Support #8

Open
sebkouba opened this issue Jan 24, 2018 · 1 comment
Open

SSH Port Support #8

sebkouba opened this issue Jan 24, 2018 · 1 comment

Comments

@sebkouba
Copy link

Hi there,
First off thanks for uploading this role! I've learned a lot from it.

It has taken me an embarrassingly long time to fully understand it, however. I needed to use non standard ssh ports which I managed in the end. Maybe somebody will find this helpful (if I find time I'll add a pull request)

For custom ssh port:

Step 1 - add the "-p" to each instance where BORG_RSH is used and define it in vars, like so:

    - BORG_RSH: "ssh -o StrictHostKeyChecking=no -i {{ borgbackup_client_ssh_key_file }} -p {{ borgbackup_ssh_port }}"

Step 2 - FQDN as ansible host name with port in hosts file

I had my hosts file set up with ports but the name wasn't the FQDN. I had to change the ansible host name from playgroung to playground.mydomain.com. With those changes I could then run the entire role on my custom ssh port.

Also the example was confusing to me. I didn't see how the role and to be run on multiple machines one after another. Maybe this makes more sense to simple people like me:

---
- hosts: borg_server
  become: true
  vars: 
    borgbackup_ssh_port: 2423
    borgbackup_server: True

  roles:
    - role: borgbackup

- hosts: some_app
  become: true
  vars:
    borgbackup_client: True
    borgbackup_ssh_port: 2423
    borgbackup_client_backup_server: my.borgserver.com

  roles:
    - role: borgbackup
      borgbackup_client_jobs:
        - name: system
          day: "*"
          hour: "0"
          minute: "{{ 59 | random }}"
          directories:
            - /home
      borgbackup_prune_jobs:
        - name: system
          prune_options: "--keep-daily=7 --keep-weekly=4"
          day: "*"
          hour: "8"
          minute: "0"

Note that the entry in my hosts.ini for ansible includes the config with the ssh port for the host name my.borgserver.com

The same role runs with a different setting of borgbackup_server vs borgbackup_client!

my.borgserver.com ansible_host=11.22.24.95 ansible_user=something ansible_ssh_private_key_file=~/path/to/id_rsa ansible_port=2423

This way the borg commands run on the specified port because of the RSH setting and Ansible understands because I have the entry in my hosts file. If there is an easier way to do this I'd be glad to hear it.

@varac
Copy link

varac commented Apr 6, 2018

I'm stepping into the same problem. Support for different ports would be much appreciated!
Maybe a more generic solution like making the BORG_RSH variable configurable would solve this and other edge cases as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants