-
Notifications
You must be signed in to change notification settings - Fork 1
/
server-2.yml
46 lines (41 loc) · 1.09 KB
/
server-2.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
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create server
openstack.cloud.server:
state: present
name: precarious_puffin
image: 'Ubuntu 22.04 Jammy Jellyfish x86_64'
flavor: b.2c4gb
volume_size: 16
boot_from_volume: true
terminate_volume: true
key_name: ansible_key
network: ansible_net
auto_ip: true
security_groups: default
wait: true
register: vm_info
- name: Add server to dynamic inventory
add_host:
groups: cleura_cloud_servers
name: '{{ vm_info.server.hostname }}'
ansible_ssh_host: '{{ vm_info.server.addresses.ansible_net[1].addr }}'
- hosts: cleura_cloud_servers
gather_facts: true
remote_user: ubuntu
become: true
vars:
ansible_ssh_private_key_file: 'ansible_key'
tasks:
- name: Update repositories package cache
apt:
update_cache: true
cache_valid_time: 3600
- name: Apply package upgrades
apt:
upgrade: dist
autoremove: true
force_apt_get: true