瀏覽代碼

vm ip config

systemd-xsession
父節點
當前提交
6f25d6fc32
共有 2 個檔案被更改,包括 16 行新增0 行删除
  1. +12
    -0
      tasks/ssh.yaml
  2. +4
    -0
      templates/ssh.config.j2

+ 12
- 0
tasks/ssh.yaml 查看文件

@@ -5,3 +5,15 @@
src: ~/ssh-keys/
dest: ~/ssh-keys
mode: u=rw,g=,o=

- name: ssh auto config
template:
src: ssh.config.j2
dest: ~/.ssh/config.auto

- name: include ssh auto config
lineinfile:
path: ~/.ssh/config
line: Include config.auto
insertbefore: BOF
create: true

+ 4
- 0
templates/ssh.config.j2 查看文件

@@ -0,0 +1,4 @@
{% for hostname in groups.vms %}
Host {{hostname}}
HostName {{hostvars[hostname].external_ip}}
{% endfor %}