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.

108 lines
3.2 KiB

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