Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows upgrade and testing [WIP] #102

Merged
merged 9 commits into from
Mar 26, 2020
Merged
3 changes: 3 additions & 0 deletions molecule/ec2_centos7/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ driver:
name: ec2
platforms:
- name: "bootstrap1-centos7-${USER:-ci}-${HOSTNAME:-local}"
spot_price: null
image: ami-9887c6e7
region: us-east-1
instance_type: m5.xlarge
Expand All @@ -13,6 +14,7 @@ platforms:
- bootstraps
- dcos
- name: master1-centos7-${USER:-ci}-${HOSTNAME:-local}
spot_price: null
image: ami-9887c6e7
region: us-east-1
instance_type: m5.xlarge
Expand All @@ -21,6 +23,7 @@ platforms:
- masters
- dcos
- name: agent1-centos7-${USER:-ci}-${HOSTNAME:-local}
spot_price: null
image: ami-9887c6e7
region: us-east-1
instance_type: m5.xlarge
Expand Down
3 changes: 3 additions & 0 deletions molecule/ec2_rhel7/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ driver:
name: ec2
platforms:
- name: bootstrap1-rhel7-${USER:-ci}-${HOSTNAME:-local}
spot_price: null
image: ami-011b3ccf1bd6db744
region: us-east-1
instance_type: m5.xlarge
groups:
- bootstraps
- dcos
- name: master1-rhel7-${USER:-ci}-${HOSTNAME:-local}
spot_price: null
image: ami-011b3ccf1bd6db744
region: us-east-1
instance_type: m5.xlarge
groups:
- masters
- dcos
- name: agent1-rhel7-${USER:-ci}-${HOSTNAME:-local}
spot_price: null
image: ami-011b3ccf1bd6db744
region: us-east-1
instance_type: m5.xlarge
Expand Down
3 changes: 3 additions & 0 deletions molecule/ec2_windows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ driver:
name: delegated
platforms:
- name: "bootstrap1-windows-${USER:-ci}-${HOSTNAME:-local}"
spot_price: null
image: ami-9887c6e7
region: us-east-1
instance_type: m5.xlarge
Expand All @@ -13,6 +14,7 @@ platforms:
- bootstraps
- dcos
- name: master1-windows-${USER:-ci}-${HOSTNAME:-local}
spot_price: null
image: ami-9887c6e7
region: us-east-1
instance_type: m5.xlarge
Expand All @@ -21,6 +23,7 @@ platforms:
- masters
- dcos
- name: winagent1-windows-${USER:-ci}-${HOSTNAME:-local}
spot_price: null
windows: true
image: ami-0105f663dc99752af
region: us-east-1
Expand Down
3 changes: 3 additions & 0 deletions roles/dcos_agent_windows/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: "Re-run setup to use custom facts"
setup: ~
listen: reload facts
8 changes: 4 additions & 4 deletions roles/dcos_agent_windows/tasks/dcos_upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
- name: Windows Upgrade | Create upgrade download directory
win_file:
path: "{{ base_windows_dir }}\\{{ hostvars[inventory_hostname]['ansible_dcos_installation']['dcos-image-commit'] | default(dcos['version']) }}"
path: "{{ base_windows_dir }}\\{{ dcos_version_specifier }}"
state: directory

- name: Windows Upgrade | Download dcos_node_upgrade.ps1
win_get_url:
url: "{{ dcos['config']['bootstrap_url'] }}/{{ dcos['version'] }}/genconf/serve/windows/upgrade_from_{{ hostvars[inventory_hostname]['ansible_dcos_installation']['version'] }}/latest/dcos_node_upgrade.ps1"
dest: "{{ base_windows_dir }}\\{{ hostvars[inventory_hostname]['ansible_dcos_installation']['dcos-image-commit'] | default(dcos['version']) }}\\dcos_node_upgrade.ps1"
url: "{{ dcos['config']['bootstrap_url'] }}/{{ dcos_version_specifier }}/genconf/serve/windows/upgrade_from_{{ hostvars[inventory_hostname]['ansible_dcos_installation']['version'] }}/latest/dcos_node_upgrade.ps1"
dest: "{{ base_windows_dir }}\\{{ dcos_version_specifier }}\\dcos_node_upgrade.ps1"
force: yes

- name: Windows Upgrade | DC/OS Upgrade
block:
- name: Windows Upgrade | Run DC/OS agent upgrade
win_shell: "{{ base_windows_dir }}\\{{ hostvars[inventory_hostname]['ansible_dcos_installation']['dcos-image-commit'] | default(dcos['version']) }}\\dcos_node_upgrade.ps1"
win_shell: "{{ base_windows_dir }}\\{{ dcos_version_specifier }}\\dcos_node_upgrade.ps1"
register: upgrade_shell_stdout

always:
Expand Down
21 changes: 15 additions & 6 deletions roles/dcos_agent_windows/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
- name: Defining DC/OS by using 'version' or, more specifically, 'image_commit'
set_fact:
dcos_version_specifier: "{{ dcos['image_commit'] | default(dcos['version']) }}"

- name: Windows | Create custom fact directory
win_file:
path: "{{ base_windows_dir }}\\etc\\ansible\\facts.d"
Expand All @@ -8,23 +13,27 @@
path: '{{ base_windows_dir }}\etc\dcos-version.json'
register: previous_installation

- name: Windows | Create dcos_installation.fact.ps1
win_copy:
content: get-content {{ base_windows_dir }}\etc\ansible\facts.d\dcos_installation.fact -Raw | ConvertFrom-Json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the content of dcos_installaton.fact file will be available after task "Copy dcos-version.json to fact directory" . Therefore I don't recommend line 16 .. 22 to be added with anything

dest: "{{ base_windows_dir }}\\etc\\ansible\\facts.d\\dcos_installation.fact.ps1"
when: previous_installation.stat.exists and previous_installation.stat.isreg
notify: reload facts

- name: Windows | Copy dcos-version.json to fact directory
win_copy:
src: "{{ base_windows_dir }}\\etc\\dcos-version.json"
dest: "{{ base_windows_dir }}\\etc\\ansible\\facts.d\\dcos_installation.fact"
remote_src: yes
when: previous_installation.stat.exists and previous_installation.stat.isreg

- name: Windows | Create dcos_installation.fact.ps1
win_copy:
content: get-content {{ base_windows_dir }}\etc\ansible\facts.d\dcos_installation.fact -Raw | ConvertFrom-Json
dest: "{{ base_windows_dir }}\\etc\\ansible\\facts.d\\dcos_installation.fact.ps1"
when: previous_installation.stat.exists and previous_installation.stat.isreg
notify: reload facts

- name: Windows | Re-run setup to use custom facts
setup:
fact_path: "{{ base_windows_dir }}\\etc\\ansible\\facts.d\\dcos_installation.fact.ps1"
when: previous_installation.stat.exists and previous_installation.stat.isreg
fatz marked this conversation as resolved.
Show resolved Hide resolved
notify: reload facts
- meta: flush_handlers

# TO DO: remove when Winpanda is able to create Mesos-DNS by its own
- name: Windows | Detect network interface with default_gateway set
Expand Down