base.yml 4.1 KB

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