You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.1 KiB

  1. ---
  2. # Role commun a toutes les machines
  3. # vars: admin_ssh_keys, repositories, default_packages, ntp_servers, description
  4. # Bootstrap if necessary (install python-apt)
  5. - name: Bootstrap if necessary
  6. tags: bootstrap
  7. raw: python -c "import apt" || DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y install python-apt
  8. when: ansible_distribution == 'Debian' and ansible_distribution_major_version|int < 11
  9. - name: Bootstrap if necessary
  10. tags: bootstrap
  11. raw: python -c "import apt" || DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y install python3-apt
  12. when: ansible_distribution == 'Debian' and ansible_distribution_major_version|int >= 11
  13. # Check mandatory variables
  14. - name: Check vars
  15. fail: msg="Missing variable default_packages_debian"
  16. when: default_packages_debian is not defined
  17. - name: Check vars
  18. fail: msg="Missing variable description"
  19. when: description is not defined
  20. - name: Check vars
  21. fail: msg="Missing variable ntp_servers"
  22. when: ntp_servers is not defined
  23. - name: Check vars
  24. fail: msg="Missing variable disable_ipv6"
  25. when: disable_ipv6 is not defined
  26. # Packages
  27. - name: Install default packages Debian.
  28. apt: pkg={{item}} state=latest update_cache=yes
  29. with_items: "{{ default_packages_debian }}"
  30. when: ansible_distribution == 'Debian'
  31. # Configure NTP
  32. - name: Configure NTP
  33. tags: ntp
  34. template: src=etc-ntp.conf.j2 dest=/etc/ntp.conf
  35. # Basic Shell & vim configuration
  36. - name: Create .vim/colors
  37. tags: custom
  38. file: path=/root/.vim/colors state=directory
  39. - name: Custom .bashrc, .vimrc, .inputrc and Wombat vim colors theme
  40. tags: custom
  41. copy: src={{ item.src }} dest={{ item.dest }}
  42. with_items:
  43. - { src: 'root-.bashrc', dest: '/root/.bashrc' }
  44. - { src: 'root-.vimrc', dest: '/root/.vimrc' }
  45. - { src: 'root-.inputrc', dest: '/root/.inputrc' }
  46. - { src: 'root-.vim-colors-wombat.vim', dest: '/root/.vim/colors/wombat.vim' }
  47. # Set motd and README.root
  48. - name: Set the motd
  49. tags: custom
  50. template: src=etc-motd.j2 dest=/etc/motd
  51. - name: Modify /root/.profile, Add basic README.root
  52. tags: custom
  53. copy: src={{ item.src }} dest={{ item.dest }}
  54. with_items:
  55. - { src: 'root-.profile', dest: '/root/.profile' }
  56. - { src: 'root-README.root', dest: '/root/README.root' }
  57. when: initialize == 'True'
  58. # Env setup
  59. - name: Set the locale
  60. tags: environ
  61. debconf: name=locales question='locales_to_be_generated' value='en_US.UTF-8 UTF-8, fr_FR.UTF-8 UTF-8' vtype='multiselect'
  62. when: ansible_distribution == 'Debian'
  63. - name: Set timezone
  64. copy: content='{{ tzdata_timezone | default('Europe/Paris') }}'
  65. dest=/etc/timezone owner=root group=root mode=0644
  66. notify:
  67. - update timezone
  68. when: ansible_distribution == 'Debian'
  69. - name: Disable IPv6 (need reboot)
  70. tags: environ
  71. lineinfile: dest=/etc/modprobe.d/blacklist line="blacklist ipv6" state="present" create="yes"
  72. when: disable_ipv6
  73. - name: Enable IPv6 (need reboot)
  74. tags: environ
  75. lineinfile: dest=/etc/modprobe.d/blacklist line="blacklist ipv6" state="absent" create="yes"
  76. when: not disable_ipv6
  77. # vim: set textwidth=0 ft=yaml ts=2 sw=2 expandtab: