Skip to content

Commit

Permalink
Change variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
x86-39 committed Sep 29, 2023
1 parent 1c8d210 commit 4da7250
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ Role Variables

Variable | Default | Description
--- | --- | ---
`rancher_rke2_role_name` | `rke2` | Name of role role in collection Rancher
`rancher_rke2_script_url` | `https://get.rke2.io` | URL of the RKE2 setup script
`rancher_rke2_channel` | `v1.24` | RKE2 release channel. v1.24 is the latest supported for Rancher
`rancher_rke2_tls_san` | `["{{ ansible_domain }}"]` | List of additional domains to add to the RKE2 server certificate
`rancher_rke2_type` | `server` | RKE2 type. Options: `[server, agent]`
`rancher_rke2_server_token` | ` ` | RKE2 server token to set. Will be generated at runtime if unset.
`rancher_rke2_server_ip` | ` ` | If this variable is set, nodes will register to this existing server. Must not be set on the initial host. To provision with Rancher, use the [rke2_agent](../rke2_agent/) role.
`rancher_rke2_server_ansible_user` | `{{ ansible_user_id }}` | User to copy the kubeconfig to ~/.kube/config
`rke2_role_name` | `rke2` | Name of role role in collection Rancher
`rke2_script_url` | `https://get.rke2.io` | URL of the RKE2 setup script
`rke2_channel` | `v1.24` | RKE2 release channel. v1.24 is the latest supported for Rancher
`rke2_tls_san` | `["{{ ansible_domain }}"]` | List of additional domains to add to the RKE2 server certificate
`rke2_type` | `server` | RKE2 type. Options: `[server, agent]`
`rke2_server_token` | ` ` | RKE2 server token to set. Will be generated at runtime if unset.
`rke2_server_ip` | ` ` | If this variable is set, nodes will register to this existing server. Must not be set on the initial host. To provision with Rancher, use the [rke2_agent](../rke2_agent/) role.
`rke2_server_ansible_user` | `{{ ansible_user_id }}` | User to copy the kubeconfig to ~/.kube/config
<!--
`variable` | `default` | Variable example
`long_variable` | See [defaults/main.yml](./defaults/main.yml) | Variable referring to defaults
Expand Down
12 changes: 6 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
rancher_rke2_role_name: "rke2"
rancher_rke2_script_url: "https://get.rke2.io"
rancher_rke2_channel: "v1.24" # Latest is 1.26, this is latest supported by Rancher
rancher_rke2_tls_san:
rke2_role_name: "rke2"
rke2_script_url: "https://get.rke2.io"
rke2_channel: "v1.24" # Latest is 1.26, this is latest supported by Rancher
rke2_tls_san:
- "{{ ansible_domain }}"

rancher_rke2_type: "server"
rancher_rke2_server_ansible_user: "{{ ansible_user_id }}"
rke2_type: "server"
rke2_server_ansible_user: "{{ ansible_user_id }}"

rke2_dependencies: "{{ _rke2_dependencies }}"
...
26 changes: 13 additions & 13 deletions tasks/setup/always.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- name: "Setup | Generate token if none was given"
ansible.builtin.set_fact:
rancher_rke2_server_token: "{{ lookup('password', '/dev/null length=64 chars=ascii_letters,digits') }}"
rke2_server_token: "{{ lookup('password', '/dev/null length=64 chars=ascii_letters,digits') }}"
delegate_to: localhost
run_once: true
when: rancher_rke2_server_token is not defined
when: rke2_server_token is not defined

- name: "Setup | Ensure RKE2 config directory exists"
become: true
Expand All @@ -27,7 +27,7 @@
- name: "Setup | Download RKE2 install script"
become: true
ansible.builtin.get_url:
url: "{{ rancher_rke2_script_url }}"
url: "{{ rke2_script_url }}"
dest: "/tmp/rke2-install.sh"
owner: root
group: root
Expand All @@ -40,8 +40,8 @@
args:
creates: "/usr/local/bin/rke2"
environment:
INSTALL_RKE2_CHANNEL: "{{ rancher_rke2_channel }}"
INSTALL_RKE2_TYPE: "{{ rancher_rke2_type }}"
INSTALL_RKE2_CHANNEL: "{{ rke2_channel }}"
INSTALL_RKE2_TYPE: "{{ rke2_type }}"

- name: "Setup | Start first RKE2 server"
become: true
Expand All @@ -50,7 +50,7 @@
state: started
enabled: true
when:
- rancher_rke2_server_ip is undefined
- rke2_server_ip is undefined
- "'molecule-notest' not in ansible_skip_tags"

- name: "Setup | Wait for RKE2 server to be ready on port 9345"
Expand All @@ -60,7 +60,7 @@
state: started
timeout: 300
when:
- rancher_rke2_server_ip is undefined
- rke2_server_ip is undefined
- "'molecule-notest' not in ansible_skip_tags"

- name: "Setup | Start other RKE2 servers"
Expand All @@ -70,7 +70,7 @@
state: started
enabled: true
when:
- rancher_rke2_server_ip is defined
- rke2_server_ip is defined
- "'molecule-notest' not in ansible_skip_tags"
retries: 5
delay: 10
Expand All @@ -80,10 +80,10 @@
- name: "Server | Ensure .kube directory exists"
become: true
ansible.builtin.file:
path: ~{{ rancher_rke2_server_ansible_user }}/.kube
path: ~{{ rke2_server_ansible_user }}/.kube
state: directory
owner: "{{ rancher_rke2_server_ansible_user }}"
group: "{{ rancher_rke2_server_ansible_user }}"
owner: "{{ rke2_server_ansible_user }}"
group: "{{ rke2_server_ansible_user }}"
mode: '0700'

- name: Check if rke2.yaml exists
Expand All @@ -96,9 +96,9 @@
become: true
ansible.builtin.copy:
src: /etc/rancher/rke2/rke2.yaml
dest: ~{{ rancher_rke2_server_ansible_user }}/.kube/config
dest: ~{{ rke2_server_ansible_user }}/.kube/config
remote_src: true
owner: "{{ rancher_rke2_server_ansible_user }}"
owner: "{{ rke2_server_ansible_user }}"
mode: "u=rw,g=,o="
when: rke2_yaml.stat.exists

Expand Down
10 changes: 5 additions & 5 deletions templates/config.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
token: {{ rancher_rke2_server_token }}
{% if rancher_rke2_server_ip is defined %}
server: https://{{ rancher_rke2_server_ip }}:9345
token: {{ rke2_server_token }}
{% if rke2_server_ip is defined %}
server: https://{{ rke2_server_ip }}:9345
{% endif %}
{% if rancher_rke2_tls_san | length > 0 %}
{% if rke2_tls_san | length > 0 %}
tls-san:
{% for san in rancher_rke2_tls_san %}
{% for san in rke2_tls_san %}
- {{ san }}
{% endfor %}
{% endif %}
2 changes: 1 addition & 1 deletion vars/default.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
rancher_rke2_role_name: "rke2"
rke2_role_name: "rke2"

...

0 comments on commit 4da7250

Please sign in to comment.