base.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. - name: 'Install hosts file'
  2. template: src=hosts.j2 dest=/etc/hosts owner=root group=root mode=0644
  3. notify:
  4. - 'Update motd'
  5. - name: 'Install hosts.deny file'
  6. template: src=hosts.deny.j2 dest=/etc/hosts.deny owner=root group=root mode=0644
  7. - name: 'Write /etc/apt/sources.list'
  8. template: src=apt/sources.{{ ansible_lsb.codename }}.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
  9. notify:
  10. - 'Reload apt cache'
  11. - name: 'Remove deprecated apt options files'
  12. file:
  13. path: '/etc/apt/apt.conf.d/{{ item }}'
  14. state: 'absent'
  15. with_items:
  16. - '90local'
  17. - name: 'Write /etc/apt/apt.conf.d configuration files'
  18. template:
  19. src: 'apt/apt-{{ item }}.j2'
  20. dest: '/etc/apt/apt.conf.d/99{{ item }}'
  21. owner: 'root'
  22. group: 'root'
  23. mode: '0644'
  24. with_items:
  25. - 'nopdiffs'
  26. - 'norecommends'
  27. - 'progressbar'
  28. - name: 'Install apt key for custom Debian repositories'
  29. apt_key:
  30. id: '{{ item.id }}'
  31. url: '{{ item.url }}'
  32. state: 'present'
  33. with_items: '{{ apt_keys }}'
  34. when: apt_keys
  35. - name: 'Add apt sources for custom Debian repositories'
  36. apt_repository:
  37. repo: 'deb {{ item.uri }} {{ ansible_lsb.codename }} {{ item.sections }}'
  38. state: 'present'
  39. with_items: '{{ apt_repositories }}'
  40. when: apt_repositories
  41. - name: 'Install base packages'
  42. apt: pkg={{ item }} install_recommends=no state=installed
  43. with_items:
  44. - 'apt-transport-https'
  45. - 'apticron'
  46. - 'locales-all'
  47. - 'locales'
  48. - 'lsb-release'
  49. - 'toilet'
  50. - 'toilet-fonts'
  51. - 'facter'
  52. - 'zsh'
  53. - 'git-core'
  54. - 'tig'
  55. - 'vim-nox'
  56. - 'ccze'
  57. - 'tree'
  58. - 'pydf'
  59. - 'htop'
  60. - 'sudo'
  61. - 'sysfsutils'
  62. - 'tmux'
  63. - 'rsync'
  64. - 'ca-certificates'
  65. - 'sysstat'
  66. - 'etckeeper'
  67. - 'sharutils'
  68. - 'ncdu'
  69. - name: 'Install additional packages'
  70. apt: pkg={{ item }} install_recommends=no state=installed
  71. with_items: '{{ apt_additional_packages }}'
  72. when: apt_additional_packages
  73. - name: 'Install ntp daemon'
  74. apt: pkg=ntp install_recommends=no state=installed
  75. when: with_ntp
  76. - name: 'Configure default locale and timezone'
  77. debconf: name="{{item.name}}" question="{{item.question}}" value="{{item.value}}" vtype="{{item.vtype}}"
  78. with_items:
  79. - { name: 'locales', question: 'locales/default_environment_locale', value: '{{ locale }}', vtype: 'select' }
  80. - { name: 'tzdata', question: 'tzdata/Areas', value: '{{ timezone_area }}', vtype: 'select' }
  81. - { name: 'tzdata', question: 'tzdata/Zones/{{ timezone_area }}', value: '{{ timezone_city }}', vtype: 'select' }
  82. notify:
  83. - 'Reconfigure locales'
  84. - 'Reconfigure timezone'
  85. - name: 'Override logrotate configuration for rsyslog'
  86. template: src=logrotate/rsyslog.j2 dest=/etc/logrotate.d/rsyslog owner=root group=root mode=0644
  87. - name: 'Install kernel configuration (proc)'
  88. template: src=kernel/sysctl.d/{{ item }}.j2 dest=/etc/sysctl.d/{{ item }} owner=root group=root mode=0644
  89. with_items:
  90. - '05-ipv6.conf'
  91. - '10-increase-file-descriptors.conf'
  92. notify:
  93. - 'Apply kernel configuration (proc)'
  94. tags:
  95. - 'ipv6'
  96. - name: 'Create sysfs configuration directory - /etc/sysfs.d'
  97. file: path=/etc/sysfs.d state=directory owner=root group=root mode=0755
  98. - name: 'Install kernel configuration (sys)'
  99. template: src=kernel/sysfs.d/{{ item }}.j2 dest=/etc/sysfs.d/{{ item }} owner=root group=root mode=0644
  100. with_items:
  101. - '00-sysfs-prolog.conf'
  102. notify:
  103. - 'Refresh sysfs configuration'
  104. - name: 'Install kernel configuration (sys) for disks'
  105. template: src=kernel/sysfs.d/{{ item }}.j2 dest=/etc/sysfs.d/{{ item }} owner=root group=root mode=0644
  106. with_items:
  107. - '10-disks.conf'
  108. notify:
  109. - 'Refresh sysfs configuration'
  110. - name: 'Install sudo configuration'
  111. template: src=sudo/local-admin.j2 dest=/etc/sudoers.d/local-admin owner=root group=root mode=0440
  112. - name: 'Install unprivileged user'
  113. user: name="{{item.user}}" comment="{{item.fullname}}" groups=adm,operator,sudo append=yes shell=/bin/zsh state=present
  114. with_items: '{{ admins }}'
  115. when: admins
  116. - name: 'Install SSH key for unprivileged user'
  117. authorized_key: user="{{item.user}}" key="{{lookup('file', 'data/users/' + item.user + '/id_rsa.pub')}}" state=present
  118. with_items: '{{ admins }}'
  119. when: admins
  120. - name: 'Install SSH key for root'
  121. authorized_key: user=root key="{{lookup('file', 'data/users/' + item.user + '/id_rsa.pub')}}" state=present
  122. with_items: '{{ admins }}'
  123. when: admins