base.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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|bool
  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|bool
  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|length > 0
  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|length > 0
  65. tags:
  66. - 'base'
  67. - name: 'Install base packages'
  68. apt:
  69. pkg:
  70. - 'apt-transport-https'
  71. - 'apticron'
  72. - 'locales-all'
  73. - 'locales'
  74. - 'lsb-release'
  75. - 'facter'
  76. - 'zsh'
  77. - 'git-core'
  78. - 'tig'
  79. - 'vim-nox'
  80. - 'ccze'
  81. - 'tree'
  82. - 'pydf'
  83. - 'htop'
  84. - 'sudo'
  85. - 'sysfsutils'
  86. - 'tmux'
  87. - 'rsync'
  88. - 'ca-certificates'
  89. - 'sysstat'
  90. - 'etckeeper'
  91. - 'sharutils'
  92. - 'ncdu'
  93. install_recommends: 'no'
  94. state: 'present'
  95. tags:
  96. - 'base'
  97. - name: 'Install additional packages'
  98. apt:
  99. pkg: '{{ apt_additional_packages }}'
  100. install_recommends: 'no'
  101. state: 'present'
  102. when: apt_additional_packages|length > 0
  103. tags:
  104. - 'base'
  105. - name: 'Install ntp daemon'
  106. apt:
  107. pkg: 'ntp'
  108. install_recommends: 'no'
  109. state: 'present'
  110. when: with_ntp|bool
  111. tags:
  112. - 'base'
  113. - name: 'Configure default locale ({{ locale }})'
  114. command: update-locale 'LANG={{ locale }}'
  115. changed_when: False
  116. when: locale is defined and locale|length > 0
  117. tags:
  118. - 'base'
  119. - name: 'Configure default timezone'
  120. debconf:
  121. name: '{{ item.name }}'
  122. question: '{{ item.question }}'
  123. value: '{{ item.value }}'
  124. vtype: '{{ item.vtype }}'
  125. with_items:
  126. - { name: 'tzdata', question: 'tzdata/Areas', value: '{{ timezone_area }}', vtype: 'select' }
  127. - { name: 'tzdata', question: 'tzdata/Zones/{{ timezone_area }}', value: '{{ timezone_city }}', vtype: 'select' }
  128. notify:
  129. - 'Reconfigure timezone'
  130. tags:
  131. - 'base'
  132. - name: 'Override logrotate configuration for rsyslog'
  133. template:
  134. src: 'logrotate/rsyslog.j2'
  135. dest: '/etc/logrotate.d/rsyslog'
  136. owner: 'root'
  137. group: 'root'
  138. mode: '0644'
  139. tags:
  140. - 'base'
  141. - name: 'Install kernel configuration (proc)'
  142. template:
  143. src: 'kernel/sysctl.d/{{ item }}.j2'
  144. dest: '/etc/sysctl.d/{{ item }}'
  145. owner: 'root'
  146. group: 'root'
  147. mode: '0644'
  148. with_items:
  149. - '05-ipv6.conf'
  150. - '10-increase-file-descriptors.conf'
  151. notify:
  152. - 'Apply kernel configuration (proc)'
  153. tags:
  154. - 'base'
  155. - 'ipv6'
  156. - name: 'Create sysfs configuration directory - /etc/sysfs.d'
  157. file:
  158. path: '/etc/sysfs.d'
  159. state: 'directory'
  160. owner: 'root'
  161. group: 'root'
  162. mode: '0755'
  163. tags:
  164. - 'base'
  165. - name: 'Install kernel configuration (sys)'
  166. template:
  167. src: 'kernel/sysfs.d/{{ item }}.j2'
  168. dest: '/etc/sysfs.d/{{ item }}'
  169. owner: 'root'
  170. group: 'root'
  171. mode: '0644'
  172. with_items:
  173. - '00-sysfs-prolog.conf'
  174. notify:
  175. - 'Refresh sysfs configuration'
  176. tags:
  177. - 'base'
  178. - name: 'Install kernel configuration (sys) for disks'
  179. template:
  180. src: 'kernel/sysfs.d/{{ item }}.j2'
  181. dest: '/etc/sysfs.d/{{ item }}'
  182. owner: 'root'
  183. group: 'root'
  184. mode: '0644'
  185. with_items:
  186. - '10-disks.conf'
  187. notify:
  188. - 'Refresh sysfs configuration'
  189. tags:
  190. - 'base'
  191. - name: 'Install sudo configuration'
  192. template:
  193. src: 'sudo/local-admin.j2'
  194. dest: '/etc/sudoers.d/local-admin'
  195. owner: 'root'
  196. group: 'root'
  197. mode: '0440'
  198. tags:
  199. - 'base'
  200. - name: 'Install unprivileged user'
  201. user:
  202. name: '{{ item.user }}'
  203. comment: '{{ item.fullname }}'
  204. groups: 'adm,operator,sudo'
  205. append: 'yes'
  206. shell: '/bin/zsh'
  207. state: 'present'
  208. with_items: '{{ admins }}'
  209. when: admins|length > 0
  210. tags:
  211. - 'base'
  212. - name: 'Install SSH key for unprivileged user'
  213. authorized_key:
  214. user: '{{ item.user }}'
  215. key: "{{ lookup('file', 'data/users/' + item.user + '/sshkey.pub') }}"
  216. state: 'present'
  217. with_items: '{{ admins }}'
  218. when: admins|length > 0
  219. tags:
  220. - 'base'
  221. - name: 'Install SSH key for root'
  222. authorized_key:
  223. user: 'root'
  224. key: "{{ lookup('file', 'data/users/' + item.user + '/sshkey.pub') }}"
  225. state: 'present'
  226. with_items: '{{ admins }}'
  227. when: admins|length > 0
  228. tags:
  229. - 'base'
  230. # vim: ft=yaml.ansible