-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall-httpd-centos-vm.yml
78 lines (70 loc) · 2.2 KB
/
install-httpd-centos-vm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
- name: "install centos vm with httpd configured"
hosts: all
vars_files:
- vars.yml
tasks:
- name: "Create Namespace {{ namespace }}"
kubernetes.core.k8s:
state: present
template: namespace.yml.j2
- name: Set cloud-init fact
ansible.builtin.set_fact:
deploy_collection_cloud_init_content: |
#cloud-config
user: cloud-user
password: admin
chpasswd:
expire: false
bootcmd:
- sudo yum install -y httpd
- sudo systemctl enable httpd
- sudo systemstl start httpd
- sudo echo "hello world" >> /var/www/html/index.html
- sudo systemctl restart httpd
- name: Create cloud-init Secret
kubernetes.core.k8s:
state: present
definition:
apiVersion: v1
kind: Secret
type: Generic
metadata:
name: "{{ cloud_init_secret }}"
namespace: "{{ namespace }}"
data:
userdata: "{{ deploy_collection_cloud_init_content | b64encode }}"
- name: "Create VirtualMachine"
kubernetes.core.k8s:
state: present
template: virtualmachine.yml.j2
- name: Wait for VM to be ready
kubernetes.core.k8s_info:
api_version: kubevirt.io/v1
kind: VirtualMachine
name: "{{ name }}"
namespace: "{{ namespace }}"
register: deploy_collection_vm
retries: 60
delay: 10
until:
- deploy_collection_vm.resources[0].status is defined
- deploy_collection_vm.resources[0].status.ready is true
- name: Wait for VM IP to be populated
kubernetes.core.k8s_info:
api_version: kubevirt.io/v1
kind: VirtualMachineInstance
name: "{{ name }}"
namespace: "{{ namespace }}"
register: deploy_collection_vmi
retries: 60
delay: 10
until: (deploy_collection_vmi.resources[0].status.interfaces[0]['ipAddress'] | default('')) | length > 0
- name: "Create Service"
kubernetes.core.k8s:
state: present
template: service.yml.j2
- name: "Create Route"
kubernetes.core.k8s:
state: present
template: route.yml.j2