main.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ---
  2. # Allgemeine Konfigurationen für alle Server
  3. - name: Enable syntax highlighting in vim by default
  4. lineinfile:
  5. dest: ~/.vimrc
  6. regexp: '^syntax '
  7. line: 'syntax on'
  8. owner: root
  9. group: root
  10. mode: 0644
  11. create: yes
  12. - name: Update .bash_profile file
  13. template:
  14. src: bash_profile.j2
  15. dest: ~/.bash_profile
  16. - name: Flush all handlers
  17. meta: flush_handlers
  18. - name: add default repo
  19. #Freifunk- und Rollen-Repos erst in den jeweiligen Rollen
  20. apt_repository:
  21. repo: "{{ item }}"
  22. state: present
  23. with_items:
  24. - "deb http://cdn-fastly.deb.debian.org/debian/ {{ ansible_distribution_release }} main"
  25. - "deb http://security.debian.org/ {{ ansible_distribution_release }}/updates main"
  26. when: ansible_distribution == "Debian"
  27. - name: Eventuelles CDROM-Repo von der Installation entfernen
  28. lineinfile:
  29. dest: /etc/apt/sources.list
  30. state: absent
  31. regexp: 'cdrom'
  32. - name: install common packages
  33. apt:
  34. pkg: "{{ item }}"
  35. update_cache: yes
  36. state: present
  37. with_items:
  38. - vim
  39. - wget
  40. - vnstat
  41. - tmux
  42. - pastebinit
  43. - htop
  44. - jnettop
  45. - iotop
  46. - tcpdump
  47. - screen
  48. - strace
  49. - socat
  50. - dnsutils
  51. - host
  52. - apt-transport-https
  53. - tshark
  54. - dwdiff
  55. - molly-guard
  56. - git
  57. - iperf3
  58. - mtr-tiny
  59. - dhcpdump
  60. - dhcping
  61. - irqbalance
  62. - build-essential
  63. - ethtool
  64. - mc
  65. - net-tools
  66. - name: uninstall unneeded packages
  67. apt:
  68. pkg: "{{ item }}"
  69. update_cache: yes
  70. state: absent
  71. with_items:
  72. - rpcbind
  73. - name: Verzeichniss für SSH-Schlüsseldatei erstellen
  74. file: path=/root/.ssh state=directory
  75. - name: SSH-Schlüsseldatei generieren
  76. template:
  77. src: authorized_keys.j2
  78. dest: /root/.ssh/authorized_keys
  79. when: administratorenteam is defined
  80. - name: SSH-Dämon Passwortanmeldung abschalten
  81. lineinfile:
  82. dest: /etc/ssh/sshd_config
  83. regexp: "^[#]?PasswordAuthentication"
  84. line: "PasswordAuthentication no"
  85. notify: reload sshd
  86. - locale_gen: name=de_DE.UTF-8 state=present
  87. - name: "Collect lograte files to update"
  88. find:
  89. paths: /etc/logrotate.d/
  90. register: logrotate_result
  91. - name: "Update logrotate cycle in /etc/logrotate.d/"
  92. replace:
  93. path: "{{item.path}}"
  94. regexp: 'daily|weekly|monthly'
  95. replace: '{{logrotate.cycle}}'
  96. with_items: '{{ logrotate_result.files }}'
  97. - name: "Update logrotate count in /etc/logrotate.d/"
  98. replace:
  99. path: "{{item.path}}"
  100. regexp: 'rotate[ \t]+[0-9]+'
  101. replace: 'rotate {{logrotate.count}}'
  102. with_items: '{{ logrotate_result.files }}'
  103. - name: Logrotate Rotationszyklus und Anzahl anpassen
  104. template:
  105. src: logrotate.conf.j2
  106. dest: /etc/logrotate.conf
  107. when: logrotate is defined
  108. - name: Setze Timeout für das stopen von Interfaces
  109. lineinfile:
  110. dest: /lib/systemd/system/networking.service.d/network-pre.conf
  111. line: "[Service]"
  112. state: present
  113. when: ansible_distribution == "Debian" and ansible_distribution_major_version == "8"
  114. - name: Setze Timeout für das stopen von Interfaces
  115. lineinfile:
  116. dest: /lib/systemd/system/networking.service.d/network-pre.conf
  117. regexp: "^TimeoutStopSec="
  118. line: "TimeoutStopSec=60"
  119. state: present
  120. when: ansible_distribution == "Debian" and ansible_distribution_major_version == "8"