base.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. - name: 'Install hosts file'
  2. template:
  3. src: 'hosts.j2'
  4. dest: '/etc/hosts'
  5. owner: 'root'
  6. group: 'root'
  7. mode: '0644'
  8. when: with_hosts
  9. tags:
  10. - 'base'
  11. - name: 'Install hosts.deny file'
  12. template:
  13. src: 'hosts.deny.j2'
  14. dest: '/etc/hosts.deny'
  15. owner: 'root'
  16. group: 'root'
  17. mode: '0644'
  18. when: with_hostsdeny
  19. tags:
  20. - 'base'
  21. - name: 'Write /etc/apt/sources.list'
  22. template:
  23. src: 'apt/sources.{{ ansible_lsb.codename }}.list.j2'
  24. dest: '/etc/apt/sources.list'
  25. owner: 'root'
  26. group: 'root'
  27. mode: '0644'
  28. register: apt_sources
  29. tags:
  30. - 'base'
  31. - name: 'Refresh apt cache'
  32. apt:
  33. update_cache: yes
  34. when: apt_sources.changed
  35. tags:
  36. - 'base'
  37. - name: 'Write /etc/apt/apt.conf.d configuration files'
  38. template:
  39. src: 'apt/apt-{{ item }}.j2'
  40. dest: '/etc/apt/apt.conf.d/99{{ item }}'
  41. owner: 'root'
  42. group: 'root'
  43. mode: '0644'
  44. with_items:
  45. - 'nopdiffs'
  46. - 'norecommends'
  47. - 'progressbar'
  48. tags:
  49. - 'base'
  50. - name: 'Install apt key for custom Debian repositories'
  51. apt_key:
  52. id: '{{ item.id }}'
  53. url: '{{ item.url }}'
  54. state: 'present'
  55. with_items: '{{ apt_keys }}'
  56. when: apt_keys
  57. tags:
  58. - 'base'
  59. - name: 'Add apt sources for custom Debian repositories'
  60. apt_repository:
  61. repo: 'deb {{ item.uri }} {{ ansible_lsb.codename }} {{ item.sections }}'
  62. state: 'present'
  63. with_items: '{{ apt_repositories }}'
  64. when: apt_repositories
  65. tags:
  66. - 'base'
  67. - name: 'Install base packages'
  68. apt:
  69. pkg: '{{ item }}'
  70. install_recommends: 'no'
  71. state: 'present'
  72. with_items:
  73. - 'apt-transport-https'
  74. - 'apticron'
  75. - 'locales-all'
  76. - 'locales'
  77. - 'lsb-release'
  78. - 'facter'
  79. - 'zsh'
  80. - 'git-core'
  81. - 'tig'
  82. - 'vim-nox'
  83. - 'ccze'
  84. - 'tree'
  85. - 'pydf'
  86. - 'htop'
  87. - 'sudo'
  88. - 'sysfsutils'
  89. - 'tmux'
  90. - 'rsync'
  91. - 'ca-certificates'
  92. - 'sysstat'
  93. - 'etckeeper'
  94. - 'sharutils'
  95. - 'ncdu'
  96. tags:
  97. - 'base'
  98. - name: 'Install additional packages'
  99. apt:
  100. pkg: '{{ item }}'
  101. install_recommends: 'no'
  102. state: 'present'
  103. with_items: '{{ apt_additional_packages }}'
  104. when: apt_additional_packages
  105. tags:
  106. - 'base'
  107. - name: 'Install ntp daemon'
  108. apt:
  109. pkg: 'ntp'
  110. install_recommends: 'no'
  111. state: 'present'
  112. when: with_ntp
  113. tags:
  114. - 'base'
  115. - name: 'Configure default locale ({{ locale }})'
  116. command: update-locale 'LANG={{ locale }}'
  117. changed_when: False
  118. when: locale is defined and locale != ''
  119. tags:
  120. - 'base'
  121. - name: 'Configure default timezone'
  122. debconf:
  123. name: '{{ item.name }}'
  124. question: '{{ item.question }}'
  125. value: '{{ item.value }}'
  126. vtype: '{{ item.vtype }}'
  127. with_items:
  128. - { name: 'tzdata', question: 'tzdata/Areas', value: '{{ timezone_area }}', vtype: 'select' }
  129. - { name: 'tzdata', question: 'tzdata/Zones/{{ timezone_area }}', value: '{{ timezone_city }}', vtype: 'select' }
  130. notify:
  131. - 'Reconfigure timezone'
  132. tags:
  133. - 'base'
  134. - name: 'Override logrotate configuration for rsyslog'
  135. template:
  136. src: 'logrotate/rsyslog.j2'
  137. dest: '/etc/logrotate.d/rsyslog'
  138. owner: 'root'
  139. group: 'root'
  140. mode: '0644'
  141. tags:
  142. - 'base'
  143. - name: 'Install kernel configuration (proc)'
  144. template:
  145. src: 'kernel/sysctl.d/{{ item }}.j2'
  146. dest: '/etc/sysctl.d/{{ item }}'
  147. owner: 'root'
  148. group: 'root'
  149. mode: '0644'
  150. with_items:
  151. - '05-ipv6.conf'
  152. - '10-increase-file-descriptors.conf'
  153. notify:
  154. - 'Apply kernel configuration (proc)'
  155. tags:
  156. - 'base'
  157. - 'ipv6'
  158. - name: 'Create sysfs configuration directory - /etc/sysfs.d'
  159. file:
  160. path: '/etc/sysfs.d'
  161. state: 'directory'
  162. owner: 'root'
  163. group: 'root'
  164. mode: '0755'
  165. tags:
  166. - 'base'
  167. - name: 'Install kernel configuration (sys)'
  168. template:
  169. src: 'kernel/sysfs.d/{{ item }}.j2'
  170. dest: '/etc/sysfs.d/{{ item }}'
  171. owner: 'root'
  172. group: 'root'
  173. mode: '0644'
  174. with_items:
  175. - '00-sysfs-prolog.conf'
  176. notify:
  177. - 'Refresh sysfs configuration'
  178. tags:
  179. - 'base'
  180. - name: 'Install kernel configuration (sys) for disks'
  181. template:
  182. src: 'kernel/sysfs.d/{{ item }}.j2'
  183. dest: '/etc/sysfs.d/{{ item }}'
  184. owner: 'root'
  185. group: 'root'
  186. mode: '0644'
  187. with_items:
  188. - '10-disks.conf'
  189. notify:
  190. - 'Refresh sysfs configuration'
  191. tags:
  192. - 'base'
  193. - name: 'Install sudo configuration'
  194. template:
  195. src: 'sudo/local-admin.j2'
  196. dest: '/etc/sudoers.d/local-admin'
  197. owner: 'root'
  198. group: 'root'
  199. mode: '0440'
  200. tags:
  201. - 'base'
  202. - name: 'Install unprivileged user'
  203. user:
  204. name: '{{ item.user }}'
  205. comment: '{{ item.fullname }}'
  206. groups: 'adm,operator,sudo'
  207. append: 'yes'
  208. shell: '/bin/zsh'
  209. state: 'present'
  210. with_items: '{{ admins }}'
  211. when: admins
  212. tags:
  213. - 'base'
  214. - name: 'Install SSH key for unprivileged user'
  215. authorized_key:
  216. user: '{{ item.user }}'
  217. key: "{{ lookup('file', 'data/users/' + item.user + '/sshkey.pub') }}"
  218. state: 'present'
  219. with_items: '{{ admins }}'
  220. when: admins
  221. tags:
  222. - 'base'
  223. - name: 'Install SSH key for root'
  224. authorized_key:
  225. user: 'root'
  226. key: "{{ lookup('file', 'data/users/' + item.user + '/sshkey.pub') }}"
  227. state: 'present'
  228. with_items: '{{ admins }}'
  229. when: admins
  230. tags:
  231. - 'base'
  232. # vim: ft=yaml.ansible