Files
a13labs.infra/ansible/roles/windows_containers/tasks/containers_install.yml
T
alexandre.pires 25d3eafa5b Add support for Ubuntu containers and WSL verification
- Implemented tasks for managing Ubuntu containers using Podman, including inspection, creation, starting, and SSH setup.
- Added verification tasks for WSL and Podman installation, machine existence, and NSSM service status.
- Created PowerShell scripts for Podman auto-start on Windows boot.
- Introduced Prometheus role with default configurations and installation tasks.
- Updated Windows SSH role to improve authorized_keys management and permissions handling.
- Modified inventory to include Windows containers host.
- Updated Grafana datasource configurations with direct IP addresses for Prometheus instances.
2026-06-07 20:35:59 +02:00

119 lines
3.5 KiB
YAML

---
# ── Phase 1: Mirantis Container Runtime (MCR) installation ────────────────
- name: Check if MCR (Docker) is already installed
ansible.windows.win_shell: |
$dockerCmd = Get-Command docker -ErrorAction SilentlyContinue
if ($dockerCmd) {
$version = (& docker --version 2>&1)
Write-Output "MCR_INSTALLED:$version"
exit 0
}
exit 1
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
register: __mcr_installed_check
changed_when: false
failed_when: false
tags:
- roles::windows_containers::install
- name: Download Mirantis install script
ansible.windows.win_get_url:
url: "{{ windows_containers_mcr_install_script_url }}"
dest: "{{ ansible_env.TEMP | default('C:\\Windows\\Temp') }}\\mcr-install.ps1"
force: false
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
when: __mcr_installed_check.rc != 0
tags:
- roles::windows_containers::install
- name: Set execution policy for current process
ansible.windows.win_shell: |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force -Scope Process
exit 0
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
when: __mcr_installed_check.rc != 0
changed_when: false
tags:
- roles::windows_containers::install
- name: Install Mirantis Container Runtime
ansible.windows.win_shell: |
& "{{ ansible_env.TEMP | default('C:\\Windows\\Temp') }}\\mcr-install.ps1" \
-Channel "{{ windows_containers_mcr_channel }}" \
-DockerVersion "{{ windows_containers_mcr_version }}"
exit $LASTEXITCODE
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
register: __mcr_install_result
changed_when: __mcr_install_result.rc == 0
when: __mcr_installed_check.rc != 0
retries: 3
delay: 30
tags:
- roles::windows_containers::install
- name: Clean up MCR install script
ansible.windows.win_file:
path: "{{ ansible_env.TEMP | default('C:\\Windows\\Temp') }}\\mcr-install.ps1"
state: absent
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
when: __mcr_installed_check.rc != 0
tags:
- roles::windows_containers::install
- name: Disable MCR telemetry (optional)
ansible.windows.win_copy:
content: '{"features":{"telemetry": false}}'
dest: "C:\\ProgramData\\docker\\config\\daemon.json"
mode: "0644"
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
notify: Restart Docker service
when: windows_containers_disable_telemetry | default(false)
tags:
- roles::windows_containers::install
- name: Restart Docker service
ansible.windows.win_shell: |
Restart-Service -Name docker -Force -ErrorAction SilentlyContinue
exit 0
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
when: __mcr_installed_check.rc != 0
changed_when: false
tags:
- roles::windows_containers::install
- name: Verify MCR (Docker) is running
ansible.windows.win_shell: |
$dockerdRunning = Get-Service -Name docker -ErrorAction SilentlyContinue
if ($dockerdRunning -and $dockerdRunning.Status -eq 'Running') {
$version = (& docker --version 2>&1)
Write-Output "MCR_SERVICE_RUNNING:$version"
exit 0
}
Write-Error "Docker service is not running"
exit 1
become: true
become_method: ansible.builtin.runas
become_user: SYSTEM
register: __mcr_service_verify
changed_when: false
until: __mcr_service_verify.rc == 0
retries: 10
delay: 10
tags:
- roles::windows_containers::install