-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathproxmox.yaml
68 lines (67 loc) · 2.05 KB
/
proxmox.yaml
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
- name: Proxmox stuff
hosts: all
vars:
name: ubuntu
tasks:
- set_fact:
yeppers: "ubuntu-{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=8') }}"
- proxmox_kvm:
api_user : root@pam
api_password: PASSWORD
api_host : 10.70.7.73
clone : ubuntutemplate # The VM source
name : "{{ yeppers }}" # The target VM name
node : proxmox
storage : local-lvm
format : qcow2
timeout : 500 # Note: The task can take a while. Adapt
- name: start vm
proxmox_kvm:
api_user: root@pam
api_password: PASSWORD
api_host: 10.70.7.73
name: "{{ yeppers }}"
node: proxmox
state: started
- name: firststuff
shell: qm list | grep "{{ yeppers }}" | awk '{ print $1 }'
register: thevmid
- name: debug
debug:
var: thevmid.stdout
- name: getstuff
shell: qm config "{{ thevmid.stdout }}" | grep ^net0 | awk -F, '{print $1}' | awk -F= '{print $2}'
register: stuff
- name: debug
debug:
var: stuff.stdout
- name: Pause for 5 minute to build app cache
ansible.builtin.pause:
minutes: 1
- name: getarp
shell: nmap -sT 10.70.7.0/24
register: nmap
- debug:
var: nmap
- name: getip
shell: arp | grep "{{ stuff.stdout|lower | regex_replace('^\\/|\\/$', '') }}" | awk '{ print $1 }'
register: theip
- debug:
var: theip
- name: Slack Notification
community.general.slack:
token: TOKEN
msg: |
### Your Server is READY!! ###
--------------------------------------
``
`Server`: "{{ yeppers }}"
`IP ADDRESS`: "{{ theip.stdout}}"
'URL': ssh://networkchuck@{{ theip.stdout }}
--------------------------------------
channel: '#ansible'
color: good
username: 'Ansible on {{ inventory_hostname }}'
link_names: 0
parse: 'none'
ignore_errors: true