Bläddra i källkod

Ensure openshift_node variables adhere to naming standard

Jeremiah Stuever 6 år sedan
förälder
incheckning
139345871f

+ 2 - 2
images/installer/root/usr/local/bin/entrypoint-provider

@@ -24,9 +24,9 @@ if ! whoami &>/dev/null; then
   echo "${USER:-default}:x:$(id -u):$(id -g):Default User:$HOME:/sbin/nologin" >> /etc/passwd
 fi
 
-# Provide a "files_dir" variable that points to inventory/dynamic/injected
+# Provide a path to the pull secret
 mkdir -p "${WORK}/inventory/dynamic/${TYPE}/group_vars/all"
-echo "files_dir: \"${FILES}\"" > "${WORK}/inventory/dynamic/${TYPE}/group_vars/all/00_default_files_dir.yml"
+echo "openshift_pull_secret_path: \"${FILES}/pull-secret\"" > "${WORK}/inventory/dynamic/${TYPE}/group_vars/all/00_pull_secret_path.yml"
 # Add any injected variable files into the group vars directory
 find "${FILES}" \( -name '*.yml' -or -name '*.yaml' -or -name vars \) -print0 | xargs -0 -L1 -I {} ln -fs {} "${WORK}/inventory/dynamic/${TYPE}/group_vars/all"
 # Avoid sudo when running locally - nothing in the image requires it.

+ 8 - 8
roles/openshift_node/defaults/main.yml

@@ -1,14 +1,14 @@
 ---
-openshift_node_kubeconfig: "{{ lookup('file', kubeconfig_path) | from_yaml }}"
+openshift_kubeconfig_path: '~/.kube/config'
+openshift_pull_secret_path: '~/pull-secret.txt'
+
+openshift_node_machineconfigpool: 'worker'
+openshift_node_tls_verify: false
+
+openshift_node_kubeconfig: "{{ lookup('file', openshift_kubeconfig_path) | from_yaml }}"
 openshift_node_bootstrap_port: 22623
-openshift_node_bootstrap_machineconfigpool: 'worker'
 openshift_node_bootstrap_server: "{{ openshift_node_kubeconfig.clusters.0.cluster.server.split(':')[0:-1] | join(':') }}:{{ openshift_node_bootstrap_port }}"
-openshift_node_bootstrap_endpoint: "{{ openshift_node_bootstrap_server }}/config/{{ openshift_node_bootstrap_machineconfigpool }}"
-
-openshift_release_image: "registry.svc.ci.openshift.org/openshift/origin-release:v4.0"
-ign_file: "/tmp/bootstrap.ign"
-pull_secret: "{{ files_dir }}/pull-secret"
-tls_verify: false
+openshift_node_bootstrap_endpoint: "{{ openshift_node_bootstrap_server }}/config/{{ openshift_node_machineconfigpool }}"
 
 openshift_node_install_packages:
   # Packages from old init/base_packages

+ 11 - 11
roles/openshift_node/tasks/config.yml

@@ -22,6 +22,11 @@
     state: yes
     persistent: yes
 
+- name: create temp directory
+  tempfile:
+    state: directory
+  register: tempfile
+
 - name: Wait for bootstrap endpoint to show up
   uri:
     url: "{{ openshift_node_bootstrap_endpoint }}"
@@ -36,22 +41,17 @@
 - name: Fetch bootstrap ignition file locally
   uri:
     url: "{{ openshift_node_bootstrap_endpoint }}"
-    dest: "{{ ign_file }}"
+    dest: "{{ tempfile.path }}/bootstrap.ign"
     validate_certs: false
 
-- name: create temp directory
-  tempfile:
-    state: directory
-  register: tempfile
-
 - name: Copy pull secret in the directory
   copy:
-    src: "{{ pull_secret }}"
+    src: "{{ openshift_pull_secret_path }}"
     dest: "{{ tempfile.path }}/pull-secret.json"
 
 - name: Get release image
   k8s_facts:
-    kubeconfig: "{{ kubeconfig_path }}"
+    kubeconfig: "{{ openshift_kubeconfig_path }}"
     kind: ClusterVersion
     name: version
   delegate_to: localhost
@@ -70,7 +70,7 @@
     openshift_release_image: "{{ clusterversion.resources[0].status.desired.image }}"
 
 - name: Pull release image
-  command: "podman pull --tls-verify={{ tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ openshift_release_image }}"
+  command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ openshift_release_image }}"
 
 - name: Get machine controller daemon image from release image
   command: "podman run --rm {{ openshift_release_image }} image machine-config-daemon"
@@ -78,14 +78,14 @@
 
 - block:
   - name: Pull MCD image
-    command: "podman pull --tls-verify={{ tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ release_image_mcd.stdout }}"
+    command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ release_image_mcd.stdout }}"
 
   - name: Apply ignition manifest
     command: "podman run {{ podman_mounts }} {{ podman_flags }} {{ mcd_command }}"
     vars:
       podman_flags: "--privileged --rm -ti {{ release_image_mcd.stdout }}"
       podman_mounts: "-v /:/rootfs -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd"
-      mcd_command: "start --node-name {{ ansible_hostname }} --once-from {{ ign_file }}"
+      mcd_command: "start --node-name {{ ansible_hostname }} --once-from {{ tempfile.path }}/bootstrap.ign"
     # MCD reboots the machine, run the task but do not wait for completion
     register: manifest_apply
     async: 900  # 15 minutes

+ 2 - 0
test/aws/scaleup.yml

@@ -33,6 +33,8 @@
       openshift_version: "4.0"
 
 - import_playbook: ../../playbooks/scaleup.yml
+  vars:
+    openshift_kubeconfig_path: "{{ kubeconfig_path }}"
 
 - name: wait for nodes to join
   hosts: new_workers