Ansible role to provision a zone on OpenIndiana
Olaf Bohlen
2020-08-19 3ada41b2e02817175192ac3e44f261ee76993a66
commit | author | age
9cdfbb 1 ---
3ada41 2 # tasks file for oi-zone
OB 3 - name: create VNICs
4   dladm_vnic:
5     name: "{{ item['logical'] }}"
6     link: "{{ item['physical'] }}"
7     vlan: "{{ item['vlan'] }}"
8   loop: "{{ oizone['nics'] }}"
9
10 - name: create filesystems
11   zfs:
12     name: "{{ item['path'] }}"
13     state: present
14     zfs_extra_properties: "{{ item['zfs_extra_properties'] }}"
15   loop: "{{ oizone['filesystems'] }}"
16   when: zfscreate
17   
18 - name: set up VM zones for master
19   solaris_zone:
20     name: "{{ oizone['name'] }}"
21     state: installed
22     path: "{{ oizone['zoneroot'] }}/{{ oizone['name'] }}"
23     config: >
24       set brand={{ oizone['brand'] }};
25       set autoboot={{ oizone['autoboot'] }};
26       {% if oizone['bootargs'] %}
27       set bootargs={{ oizone['bootargs'] }};
28       {% endif %}
29       set ip-type={{ oizone['iptype'] }};
30       {% for nic in oizone['nics'] %}
31       add net;
32       set physical={{ nic['logical'] }};
33       {% if {{ oizone['iptype'] == "shared" %}
34       set address={{ nic['address'] }};
35       {% endif %}
36       end;
37       {% endfor %}
38       {% for disk in vmconfig[outer_item]['disks'] %}
39       add device;
40       set match="/dev/zvol/rdsk/localstripe/vm/{{ outer_item }}d{{ disk['instance'] }}";
41       end;
42       add attr;
43       set name="{{ disk['label'] }}";
44       set type="string";
45       set value="localstripe/vm/{{ outer_item }}d{{ disk['instance'] }}";
46       end;
47       {% endfor %}
48       {% if oizone['cpus'] == "dedicated" %}
49       add dedicated-cpu;
50       set ncpus={{ oizone['ncpus'] }};
51       end;
52       {% endif %}
53       {% if oizone['cpus'] == "capped-cpu" %}
54       add capped-cpu;
55       set ncpus={{ oizone['ncpus'] }};
56       end;
57       {% endif %}
58       {% if oizone['mem'] == "capped-memory" %}
59       add capped-memory;
60       set physical={{ oizone['ram'] }};
61       set swap={{ oizone['swap'] }};
62       set locked={{ oizone['locked'] }};
63       end;
64       {% endif %}
65       {% for dataset in oizone['filesystems'] %}
66       {% if dataset['type'] == "dataset" %}
67       add dataset;
68       set name={{ dataset['path'] }};
69       end;
70       {% endif %}
71       {% if dataset['type'] == "lofs" %}
72       add fs;
73       set special={{ dataset['path'] }};
74       set dir={{ dataset['mountpoint'] }};
75       set type="lofs";
76       {% for option in database['options'] %}
77       add options {{ option }};
78       {% endfor %}
79       end;
80       {% endif %}
81       {% if dataset['type'] == "volume" %}
82       add device;
83       set match=/dev/zvol/rdsk/{{ dataset['path'] }};
84       end;
85       {% endif %}
86       {% endfor %}
87       {% if oizone['brand'] == "kvm" %}
88       add attr;
89       set name="bootorder";
90       set type="string";
91       set value="{{ oizone['kvm']['bootorder'] }}";
92       add attr;
93       set name="vnc";
94       set type="string";
95       set value="{{ oizone['kvm']['vnc'] }}";
96       end;
97       add attr;
98       set name="vcpus";
99       set type="string";
100       set value="{{ oizone['ncpus'] }}";
101       end;
102       add attr;
103       set name="ram";
104       set type="string";
105       set value="{{ oizone['ram'] }}";
106       end;
107       {% endif %}
108
109 - name: create a sysding.conf
110   template:
111     dest: "{{ oizone['zoneroot'] }}/{{ oizone['name'] }}/root/etc/sysding.conf"
112     src: sysding.j2