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" |
| 40 | |
Petr Ospalý | 67acfb5 | 2019-04-20 05:25:23 +0200 | [diff] [blame] | 41 | - name: Prepare rke addon manifest (dashboard) |
| 42 | template: |
| 43 | src: kubernetes-dashboard.yaml.j2 |
| 44 | dest: "{{ cluster_config_dir }}/kubernetes-dashboard.yml" |
| 45 | |
| 46 | - name: Prepare rke addon manifest (dashboard user) |
| 47 | template: |
| 48 | src: k8s-dashboard-user.yml.j2 |
| 49 | dest: "{{ cluster_config_dir }}/k8s-dashboard-user.yml" |
| 50 | |
Petr Ospalý | fe49ee9 | 2019-04-20 00:53:01 +0200 | [diff] [blame] | 51 | - name: Install rke cli tool |
| 52 | copy: |
| 53 | src: "{{ app_data_path }}/downloads/{{ rke_binary }}" |
| 54 | dest: "{{ rke_bin_dir }}/rke" |
| 55 | remote_src: true |
| 56 | mode: 0755 |