Adding multiples ansible roles, playbooks and inventory
This commit is contained in:
17
roles/proxmox/tasks/ct_create.yml
Normal file
17
roles/proxmox/tasks/ct_create.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Create new container
|
||||
community.general.proxmox:
|
||||
node: "{{ proxmox_node }}"
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_password: "{{ proxmox_api_password }}"
|
||||
hostname: "{{ proxmox_ct_create_hostname }}"
|
||||
pubkey: "{{ proxmox_ct_create_pubkey }}"
|
||||
ostemplate: "{{ proxmox_ct_create_ostemplate }}"
|
||||
cores: 2
|
||||
memory: "{{ proxmox_ct_create_ram }}"
|
||||
swap: "{{ proxmox_ct_create_swap}}"
|
||||
netif: "{{ proxmox_ct_create_net_config }}"
|
||||
vmid: "{{ proxmox_ct_create_vmid | default(999999) }}"
|
||||
tags: "{{ proxmox_ct_create_tags}}"
|
||||
...
|
||||
25
roles/proxmox/tasks/ct_remove.yml
Normal file
25
roles/proxmox/tasks/ct_remove.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: Get VMID
|
||||
ansible.builtin.shell: >-
|
||||
pct list | awk '{print $1,$3}' | grep -E '^[0-9]+ {{ proxmox_ct_name }}$'| awk '{print $1}'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: vmid
|
||||
delegate_to: "{{ proxmox_node }}"
|
||||
|
||||
|
||||
- name: Stop container
|
||||
community.general.proxmox:
|
||||
vmid: "{{ vmid.stdout }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_password: "{{ proxmox_api_password }}"
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
state: stopped
|
||||
|
||||
- name: Remove container
|
||||
community.general.proxmox:
|
||||
vmid: "{{ vmid.stdout }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_password: "{{ proxmox_api_password }}"
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
state: absent
|
||||
18
roles/proxmox/tasks/main.yml
Normal file
18
roles/proxmox/tasks/main.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Proxmox Create new container
|
||||
ansible.builtin.include_tasks:
|
||||
file: ct_create.yml
|
||||
apply:
|
||||
tags:
|
||||
- ct_create
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Proxmox Remove contrainer
|
||||
ansible.builtin.include_tasks:
|
||||
file: ct_remove.yml
|
||||
apply:
|
||||
tags:
|
||||
- ct_remove
|
||||
tags:
|
||||
- always
|
||||
4
roles/proxmox/tasks/test.yml
Normal file
4
roles/proxmox/tasks/test.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
- name: Testing
|
||||
ansible.builtin.debug:
|
||||
msg: "nzefùînfùaineaùzifnazùeifnaze"
|
||||
Reference in New Issue
Block a user