Petr Ospalý | fe49ee9 | 2019-04-20 00:53:01 +0200 | [diff] [blame] | 1 | --- |
| 2 | - name: "Ensure the .ssh directory exists" |
| 3 | file: |
| 4 | path: "{{ ansible_env.HOME }}/.ssh" |
| 5 | mode: 0700 |
| 6 | state: directory |
| 7 | |
| 8 | - name: Add kubernetes nodes host keys to known_hosts file |
| 9 | known_hosts: |
| 10 | name: "{{ hostvars[item].cluster_ip }}" |
| 11 | key: "{{ hostvars[item].cluster_ip }} ssh-rsa {{ hostvars[item].ansible_ssh_host_key_rsa_public }}" |
| 12 | hash_host: true |
| 13 | state: present |
| 14 | loop: "{{ groups['kubernetes'] }}" |
| 15 | |
| 16 | - name: "Ensure {{ cluster_config_dir }} is present" |
| 17 | file: |
| 18 | path: "{{ cluster_config_dir }}" |
| 19 | state: directory |
| 20 | mode: 0755 |
| 21 | |
| 22 | - name: Generate cluster wide ssh key pair |
| 23 | command: "ssh-keygen -q -b 4096 -t rsa -N '' -f {{ cluster_config_dir }}/cluster_key" |
| 24 | args: |
| 25 | creates: "{{ cluster_config_dir }}/cluster_key" |
| 26 | |
| 27 | - name: Get ssh public key |
| 28 | slurp: |
| 29 | src: "{{ cluster_config_dir }}/cluster_key.pub" |
| 30 | register: cluster_public_key_out |
| 31 | |
| 32 | - name: Decode ssh public key |
| 33 | set_fact: |
| 34 | cluster_public_key: "{{ cluster_public_key_out.content | b64decode }}" |
| 35 | |
| 36 | - name: Prepare rke cluster.yml |
| 37 | template: |
| 38 | src: cluster.yml.j2 |
| 39 | dest: "{{ cluster_config_dir }}/cluster.yml" |
Michal Zegan | 1ec19b0 | 2019-04-30 14:52:13 +0200 | [diff] [blame] | 40 | register: cluster_yml |
Petr Ospalý | fe49ee9 | 2019-04-20 00:53:01 +0200 | [diff] [blame] | 41 | |
Petr Ospalý | 67acfb5 | 2019-04-20 05:25:23 +0200 | [diff] [blame] | 42 | - name: Prepare rke addon manifest (dashboard) |
| 43 | template: |
| 44 | src: kubernetes-dashboard.yaml.j2 |
| 45 | dest: "{{ cluster_config_dir }}/kubernetes-dashboard.yml" |
| 46 | |
| 47 | - name: Prepare rke addon manifest (dashboard user) |
| 48 | template: |
| 49 | src: k8s-dashboard-user.yml.j2 |
| 50 | dest: "{{ cluster_config_dir }}/k8s-dashboard-user.yml" |
| 51 | |
Petr Ospalý | fe49ee9 | 2019-04-20 00:53:01 +0200 | [diff] [blame] | 52 | - name: Install rke cli tool |
| 53 | copy: |
| 54 | src: "{{ app_data_path }}/downloads/{{ rke_binary }}" |
| 55 | dest: "{{ rke_bin_dir }}/rke" |
| 56 | remote_src: true |
| 57 | mode: 0755 |