Skip to content

Commit

Permalink
move deploy_vms_cluster playbook to role
Browse files Browse the repository at this point in the history
Signed-off-by: Florent CARLI <florent.carli@rte-france.com>
  • Loading branch information
insatomcat committed Oct 8, 2024
1 parent a88c298 commit 7879ade
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 30 deletions.
10 changes: 4 additions & 6 deletions playbooks/deploy_vms_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
gather_facts: false
become: true
tasks:
- name: "Deploy VMs"
include_tasks: tasks/deploy_vm.yaml
loop: "{{ groups['VMs'] }}"
- name: "Define colocation constraints"
include_tasks: tasks/colocation.yaml
loop: "{{ groups['VMs'] }}"
- name: Deploy VMs on Cluster Role
with_items: "{{ groups['VMs'] }}"
include_role:
name: deploy_vms_cluster
7 changes: 0 additions & 7 deletions playbooks/tasks/colocation.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions playbooks/tasks/deploy_vm_from_template.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions roles/deploy_vms_cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Deploy VMs on Cluster Seapath Role

This role deploys Guests in cluster mode

## Requirements

no requirement.

## Role Variables

the role uses the "VMs" group in the inventory
and the following variables:
- qcow2tmpuploadfolder

## Example Playbook

```yaml
- hosts: cluster_machines
roles:
- { role: seapath_ansible.deploy_vms_cluster }
```
13 changes: 13 additions & 0 deletions roles/deploy_vms_cluster/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (C) 2024 RTE
# SPDX-License-Identifier: Apache-2.0
---
galaxy_info:
author: "Seapath"
description: deploys Guests in cluster mode
license: Apache-2.0
min_ansible_version: 2.9.10
platforms:
- name: Linux
versions:
- all
dependencies: []
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright (C) 2021, RTE (http://www.rte-france.com)
# Copyright (C) 2024 Savoir-faire Linux, Inc
# Copyright (C) 2024, RTE (http://www.rte-france.com)
# SPDX-License-Identifier: Apache-2.0
# Task to deploy a VM

---
- name: "check presence of vm before copy"
Expand Down Expand Up @@ -67,3 +65,11 @@
vm_file_dest: "{{ qcow2tmpuploadfolder | default('/tmp') + '/os.qcow2' }}"

when: presencevm.status == "Undefined" or (hostvars[item].force is defined and hostvars[item].force)

- name: "Define colocation constraints for {{ item }}"
cluster_vm:
name: "{{ item }}"
command: define_colocation
strong: "{{ hostvars[item].strong_colocation | default(false) }}"
colocated_vms: "{{ hostvars[item].colocated_vms }}"
when: hostvars[item].colocated_vms is defined

0 comments on commit 7879ade

Please sign in to comment.