github.com/Cloud-Foundations/Dominator@v0.3.4/user-guide/making-images.md (about) 1 # Making Images 2 A collection of recipes to make images. These assume you have generated image 3 content by some means. See the guide on 4 [manifest-driven image building](image-manifest.md) for how to build image 5 content easily and quickly. 6 7 ## I just want to push a few files to my machines 8 You can do this with a *sparse* image. Unlike regular images where files on the 9 machines may be removed if they are not in the image, with *sparse* images only 10 the files present in the image are pushed to the machines. All other files are 11 left alone. 12 13 ### I don't want to restart any services. Just push the files 14 In this case, you don't provide a *triggers* file. Normally, *triggers* are used 15 to tell the **Dominator** that the specified services should be restarted when 16 certain files are changed. 17 18 First, you will need to add your image to the imageserver. Run this command: 19 20 ``` 21 imagetool -imageServerHostname=imageserver.my.domain add sparse.0 path "" "" 22 ``` 23 24 This will package up the files in the directory tree `path` and will upload them 25 to the imageserver `imageserver.my.domain`, creating the image `sparse.0`. 26 If `path` is a tarfile (extension `.tar`) or a compressed tarfile (extension 27 `.tar.gz`), then the contents of the tarfile are uploaded. 28 29 ### Show me what I just created 30 You can see the new image in the list of images using the following command: 31 32 ``` 33 imagetool -imageServerHostname=imageserver.my.domain list 34 ``` 35 36 You can show the contents of the image (the SHA-512 hashes of regular files are 37 shown) using the following command: 38 39 ``` 40 imagetool -imageServerHostname=imageserver.my.domain show sparse.0 41 ``` 42 43 ### My image looks good. I'm ready to push it 44 All you need to do is decide which machine(s) you want to push the new image to 45 and edit the MDB (Machine Data Base) records for those machines. For each 46 machine record, you need to create/update the *RequiredImage* field with the 47 name of your new image (`sparse.0` in this example). Shortly afterwards the 48 **[Dominator](../cmd/dominator/README.md)** will pick up the updated MDB data 49 and will push the new image to the appropriate machines. If machines are down, 50 they will be automatically updated once they are back online. Your work is done. 51 52 ### I changed my mind. I want to restart a service 53 Imagine that your *sparse* image has the SSH daemon configuration file: 54 `/etc/ssh/sshd.conf` and you want to restart sshd if the file changes. You will 55 need to create a file with the following content: 56 57 ``` 58 [ 59 { 60 "MatchLines": [ 61 "/etc/ssh/sshd[.]conf", 62 "/usr/sbin/sshd" 63 ], 64 "Service": "sshd" 65 } 66 ] 67 ``` 68 69 This says that whenever the `/etc/ssh/sshd.conf` or `/usr/sbin/sshd` files are 70 changed (note the regular expression syntax), the `sshd` service should be 71 restarted (normally the command `service sshd stop; service sshd start` commands 72 are executed). If this triggers configuration is stored in the file 73 `/tmp/triggers.sshd` then you could use the following command to create the 74 image, this time with the triggers configuration: 75 76 ``` 77 imagetool -imageServerHostname=imageserver.my.domain add sparse.0 path "" /tmp/triggers.sshd 78 ``` 79 80 ## I've realised I want total *Domination* 81 You've discovered how powerful it is to push a few files to your machines and 82 have them constantly kept in compliance without having to do further work, and 83 now you want to control the whole root file-systems of your machines. For this 84 you will need to create normal images rather than *sparse* images. With normal 85 images you will need to specify a *filter*. This tells the **Dominator** that 86 certain files should not be updated. For example, you probably don't want to be 87 updating the `/etc/fstab` or `/etc/hostname` files, since they will be different 88 on each machine. 89 90 A filter file is a simple text file with a list of filter lines, each being a 91 regular expression pathname that you want to exclude from changes. An example 92 filter file may contain: 93 94 ``` 95 /etc/fstab 96 /etc/hostname 97 /tmp/.* 98 /var/log/.* 99 /var/mail/.* 100 /var/spool/.* 101 /var/tmp/.* 102 ``` 103 104 If this is contained in the file `/tmp/filter` then you would use the following 105 command to create an image: 106 107 ``` 108 imagetool -imageServerHostname=imageserver.my.domain add image.0 path /tmp/filter /tmp/triggers 109 ``` 110 111 The main difference between this command and the one shown earlier is that 112 `/tmp/filter` is passed for the name of the filter file rather than an empty 113 string. 114 115 This will package up the files in the directory tree `path` and will upload them 116 to the imageserver `imageserver.my.domain`, creating the image `image.0`. 117 If `path` is a tarfile (extension `.tar`) or a compressed tarfile (extension 118 `.tar.gz`), then the contents of the tarfile are uploaded.