Ansible role to provision a zone on OpenIndiana
Olaf Bohlen
2020-08-25 e7b69ff4c5a13600b9fc1e20a93ff8fec4237bc7
commit | author | age
9cdfbb 1 Role Name
OB 2 =========
3
4b5fae 4 This role is supposed to deploy a new OpenIndiana Zone, with different settings. It will also allow to provision (multiple) ZFS filesystems,
OB 5 vnics and other related resources.
9cdfbb 6
OB 7 Requirements
8 ------------
9
4b5fae 10 This role obiously requires an OpenIndiana host system and following ansible modules:
OB 11 - solaris_zone
12 - zfs
13 - dladm_vnic
9cdfbb 14
OB 15 Role Variables
16 --------------
17
4b5fae 18 You need to create a data structure called "oizone". The mandatory minimum is shown here:
OB 19 ``
20 oizone:
21   name: myzone
22   zoneroot: /export/zones/
23   filesystems:
24     - path: rpool/export/zones/myzone
25       type: zoneroot
26       zfscreate: true
27       zfs_extra_properties:
28         mountpoint: /export/zones/myzone
29   nics:
30     - physical: ixgbe0
31       logical: myzone0
32       address: 10.23.42.23/24
33       addrsuffix: v4
34   sysding:
35     timezone: UTC
36     locale: C
37     ip:
38       routes:
39         - target: default # can be a CIDR or a host ip or "default"
40           router: 10.23.42.1 # IP of the router
41       dns:
42         nameservers:
43           - 1.1.1.1
44           - 8.8.8.8
45         search:
46           - example.com
47           - openindiana.org
48         domain: example.com
49     users:
50       - name: root
51         hashedpassword: "$5$foobar...."
52       - name: localadm
53         uid: 100
54         gid: 10
55         shell: /usr/bin/bash
56         gecos: "Local Admin Account"
57         home: /export/home/localadm
58         hashedpassword: "$5$barfoo...."
59 ``
60
61 A set of all possible attributes is here:
62
63 ``
64 oizone:
65   name: oizone
66   updateinventory: true # adds zone on top of your inventory
67   zoneroot: /export/zones/
68   autoboot: "true"
69   bootargs: # -v
70   iptype: exclusive
71   cpus: dedicated # dedicated or capped-cpu
72   ncpus: 1
73   mem: capped-memory # or nil
74   ram: 1G
75   swap: 1G
76   locked: 1G
77   brand: ipkg
78   filesystems:
79     - path: rpool/export/zones/oizone
80       type: zoneroot
81       zfscreate: true
82       zfs_extra_properties:
83         refquota: 10G
84     mountpoint: /export/zones/oizone
85     - path: apppool/oizone/datavol1
86       type: volume
87       zfscreate: true
88       zfs_extra_properties:
89         volsize: 5G
90     - path: apppool/oizone/dataset1
91       type: dataset
92       zfscreate: true
93       zfs_extra_properties:
94         quota: 2G
95     - path: /disk1
96       type: lofs
97       mountpoint: /hostdisks/disk1
98       zfscreate: false
99       options:
100         - ro
101         - nodevices
102   nics:
103     - physical: ixgbe0
104       logical: oizoneint0
105       vlan: 100
106       address: dhcp  # can be "dhcp" or a regular IP address
107       addrsuffix: v4 # can be a string, interface0/suffix will be the ipadm create-addr
108   kvm:
109     vnc: "on"
110     bootorder: cd
111   sysding:
112     timezone: UTC
113     locale: C
114     ip:
115       routes:
116         - target: default # can be a CIDR or a host ip or "default"
117           router: 172.18.0.200 # IP of the router
118       dns:
119         nameservers:
120           - 1.1.1.1
121           - 8.8.8.8
122         search:
123           - example.com
124           - openindiana.org
125         domain: example.com
126     users:
127       - name: root
128         hashedpassword: "$5$foobar...."
129       - name: localadm
130         uid: 100
131         gid: 10
132         shell: /usr/bin/bash
133         gecos: "Local Admin Account"
134         home: /export/home/localadm
135         hashedpassword: "$5$barfoo...."
136 ``
9cdfbb 137
OB 138 Dependencies
139 ------------
140
4b5fae 141 No dependencies to others roles so far.
9cdfbb 142
OB 143 Example Playbook
144 ----------------
145
146 Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
147
148     - hosts: servers
4b5fae 149       vars:
OB 150         - oizone:
151         [... see above ..]
9cdfbb 152       roles:
4b5fae 153          - role: oi-zone
9cdfbb 154
OB 155 License
156 -------
157
4b5fae 158 BSD 3-Clause
OB 159
160 Copyright 2020 Olaf Bohlen
161
162 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
163
164 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
165
166 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
167
168 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
169
170 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9cdfbb 171
OB 172 Author Information
173 ------------------
174
4b5fae 175 Olaf Bohlen <olbohlen@eenfach.de>