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. - ncdu
  58. - name: Install additional packages
  59. apt: pkg={{ item }} install_recommends=no state=installed update_cache=yes
  60. with_items: apt_additional_packages
  61. when: apt_additional_packages
  62. - name: Install ntp daemon
  63. apt: pkg=ntp install_recommends=no state=installed update_cache=yes
  64. when: with_ntp
  65. - name: Configure default locale and timezone
  66. debconf: name="{{item.name}}" question="{{item.question}}" value="{{item.value}}" vtype="{{item.vtype}}"
  67. with_items:
  68. - { name: 'locales', question: 'locales/default_environment_locale', value: '{{ locale }}', vtype: 'select' }
  69. - { name: 'tzdata', question: 'tzdata/Areas', value: '{{ timezone_area }}', vtype: 'select' }
  70. - { name: 'tzdata', question: 'tzdata/Zones/{{ timezone_area }}', value: '{{ timezone_city }}', vtype: 'select' }
  71. notify:
  72. - Reconfigure locales
  73. - Reconfigure timezone
  74. - name: Override logrotate configuration for rsyslog
  75. template: src=logrotate/rsyslog.j2 dest=/etc/logrotate.d/rsyslog owner=root group=root mode=0644
  76. - name: Install kernel configuration (proc)
  77. template: src=kernel/sysctl.d/{{ item }}.j2 dest=/etc/sysctl.d/{{ item }} owner=root group=root mode=0644
  78. with_items:
  79. - 10-increase-file-descriptors.conf
  80. notify:
  81. - Apply kernel configuration (proc)
  82. - name: Create sysfs configuration directory - /etc/sysfs.d
  83. file: path=/etc/sysfs.d state=directory owner=root group=root mode=0755
  84. - name: Install kernel configuration (sys)
  85. template: src=kernel/sysfs.d/{{ item }}.j2 dest=/etc/sysfs.d/{{ item }} owner=root group=root mode=0644
  86. with_items:
  87. - 00-sysfs-prolog.conf
  88. notify:
  89. - Refresh sysfs configuration
  90. - name: Install kernel configuration (sys) for disks
  91. template: src=kernel/sysfs.d/{{ item }}.j2 dest=/etc/sysfs.d/{{ item }} owner=root group=root mode=0644
  92. with_items:
  93. - 10-disks.conf
  94. notify:
  95. - Refresh sysfs configuration
  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