aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2017-08-14 19:02:29 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2017-08-24 00:33:58 +0200
commitba2cf1b5d938810077b0fd73844faf432e8e8f9d (patch)
tree40884fcc70af8eb349979b2ff62e3e4435bae5a5 /modules
parenteb9fec57fcfcc84f0e310e343167a10fb13ca0c8 (diff)
downloadPuppet-ba2cf1b5d938810077b0fd73844faf432e8e8f9d.tar.gz
Puppet-ba2cf1b5d938810077b0fd73844faf432e8e8f9d.tar.zst
Puppet-ba2cf1b5d938810077b0fd73844faf432e8e8f9d.zip
Install OVH vps from scratch
Diffstat (limited to 'modules')
-rw-r--r--modules/base_configuration/files/en-dhcp.network8
-rw-r--r--modules/base_configuration/files/getty_conf_override.conf2
-rw-r--r--modules/base_configuration/files/pcspkr_no_autoload.conf1
-rw-r--r--modules/base_configuration/manifests/init.pp94
-rw-r--r--modules/base_packages/manifests/init.pp5
-rw-r--r--modules/cron_puppet/files/post-merge4
-rw-r--r--modules/cron_puppet/manifests/init.pp8
-rw-r--r--modules/etckeeper/manifests/run.pp7
m---------modules/fail2ban0
-rw-r--r--modules/grub_install/files/config47
-rw-r--r--modules/grub_install/manifests/init.pp32
-rw-r--r--modules/locales/manifests/init.pp4
12 files changed, 188 insertions, 24 deletions
diff --git a/modules/base_configuration/files/en-dhcp.network b/modules/base_configuration/files/en-dhcp.network
new file mode 100644
index 0000000..6eef0e9
--- /dev/null
+++ b/modules/base_configuration/files/en-dhcp.network
@@ -0,0 +1,8 @@
1[Match]
2Name=en*
3
4[Network]
5DHCP=yes
6
7[DHCP]
8UseMTU=true
diff --git a/modules/base_configuration/files/getty_conf_override.conf b/modules/base_configuration/files/getty_conf_override.conf
new file mode 100644
index 0000000..52671c7
--- /dev/null
+++ b/modules/base_configuration/files/getty_conf_override.conf
@@ -0,0 +1,2 @@
1[Service]
2TTYVTDisallocate=no
diff --git a/modules/base_configuration/files/pcspkr_no_autoload.conf b/modules/base_configuration/files/pcspkr_no_autoload.conf
new file mode 100644
index 0000000..b46792e
--- /dev/null
+++ b/modules/base_configuration/files/pcspkr_no_autoload.conf
@@ -0,0 +1 @@
blacklist pcspkr
diff --git a/modules/base_configuration/manifests/init.pp b/modules/base_configuration/manifests/init.pp
index a46dd8b..8b2ce4c 100644
--- a/modules/base_configuration/manifests/init.pp
+++ b/modules/base_configuration/manifests/init.pp
@@ -1,27 +1,59 @@
1class base_configuration ( 1class base_configuration (
2 $hostname = undef, 2 $hostname = undef,
3 $username = "immae", 3 $username = "immae",
4 $userid = 1000 4 $userid = 1000,
5 $code_path = undef,
6 $device = undef,
5) { 7) {
8 unless empty($device) {
9 class { 'grub_install':
10 device => $device,
11 }
12 }
13
14 class { 'locales': }
15
16 unless empty($code_path) {
17 class { 'cron_puppet':
18 code_path => $code_path,
19 }
20 }
21
6 service { "sshd": 22 service { "sshd":
7 ensure => "running", 23 #ensure => "running",
8 enable => true, 24 enable => true,
9 } 25 }
10 service { "systemd-networkd.socket": 26 service { "systemd-networkd":
11 ensure => "running", 27 #ensure => "running",
12 enable => true, 28 enable => true,
13 } 29 }
14 service { "systemd-networkd": 30 service { "systemd-resolved":
15 ensure => "running", 31 #ensure => "running",
16 enable => true, 32 enable => true,
17 } 33 }
18 34
35 file { "/etc/localtime":
36 ensure => "link",
37 target => "../usr/share/zoneinfo/Europe/Paris"
38 }
39
40 exec { "set_locale":
41 command => "/usr/bin/systemd-firstboot --locale=fr_FR.UTF-8",
42 creates => "/etc/locale.conf",
43 }
44
19 unless empty($hostname) { 45 unless empty($hostname) {
20 class { 'systemd::hostname': 46 exec { "set_hostname":
21 hostname => $hostname 47 command => "/usr/bin/systemd-firstboot --hostname=$hostname",
48 creates => "/etc/hostname",
22 } 49 }
23 } 50 }
24 51
52 file { "/etc/vconsole.conf":
53 ensure => "link",
54 target => "/dev/null",
55 }
56
25 user { "${username}:${userid}": 57 user { "${username}:${userid}":
26 name => $username, 58 name => $username,
27 uid => $userid, 59 uid => $userid,
@@ -70,6 +102,42 @@ class base_configuration (
70 password => '!' 102 password => '!'
71 } 103 }
72 104
105 file { '/etc/modprobe.d/pcspkr_no_autoload.conf':
106 ensure => "present",
107 path => "/etc/modprobe.d/pcspkr_no_autoload.conf",
108 source => 'puppet:///modules/base_configuration/pcspkr_no_autoload.conf',
109 mode => "0644",
110 owner => "root",
111 group => "root"
112 }
113
114 file { '/etc/systemd/system/getty@tty1.service.d/':
115 ensure => "directory",
116 path => "/etc/systemd/system/getty@tty1.service.d/",
117 mode => "0755",
118 owner => "root",
119 group => "root"
120 }
121
122 file { '/etc/systemd/system/getty@tty1.service.d/noclear.conf':
123 ensure => "present",
124 path => "/etc/systemd/system/getty@tty1.service.d/noclear.conf",
125 source => 'puppet:///modules/base_configuration/getty_conf_override.conf',
126 recurse => true,
127 mode => "0644",
128 owner => "root",
129 group => "root"
130 }
131
132 file { '/etc/systemd/network/en-dhcp.network':
133 ensure => "present",
134 path => "/etc/systemd/network/en-dhcp.network",
135 source => 'puppet:///modules/base_configuration/en-dhcp.network',
136 mode => "0644",
137 owner => "root",
138 group => "root"
139 }
140
73 file { '/etc/pacman.d/mirrorlist': 141 file { '/etc/pacman.d/mirrorlist':
74 ensure => "present", 142 ensure => "present",
75 path => "/etc/pacman.d/mirrorlist", 143 path => "/etc/pacman.d/mirrorlist",
@@ -108,7 +176,7 @@ class base_configuration (
108 create_mode => '0664', 176 create_mode => '0664',
109 create_owner => 'root', 177 create_owner => 'root',
110 create_group => 'utmp', 178 create_group => 'utmp',
111 rotate => '1', 179 rotate => 1,
112 minsize => '1M', 180 minsize => '1M',
113 } 181 }
114 logrotate::rule { 'btmp': 182 logrotate::rule { 'btmp':
@@ -119,7 +187,7 @@ class base_configuration (
119 create_mode => '0600', 187 create_mode => '0600',
120 create_owner => 'root', 188 create_owner => 'root',
121 create_group => 'utmp', 189 create_group => 'utmp',
122 rotate => '1', 190 rotate => 1,
123 } 191 }
124 192
125 ensure_packages(["whois"], { 'install_options' => '--asdeps' }) 193 ensure_packages(["whois"], { 'install_options' => '--asdeps' })
@@ -136,4 +204,6 @@ class base_configuration (
136 logpath => '', 204 logpath => '',
137 order => 10 205 order => 10
138 } 206 }
207
208 class { 'aur': }
139} 209}
diff --git a/modules/base_packages/manifests/init.pp b/modules/base_packages/manifests/init.pp
index 269ca58..c4bbec9 100644
--- a/modules/base_packages/manifests/init.pp
+++ b/modules/base_packages/manifests/init.pp
@@ -1,6 +1,9 @@
1class base_packages { 1class base_packages {
2 # Preinstalled 2 # Preinstalled
3 ensure_packages(['base', 'openssh', 'grub', 'sudo']) 3 ensure_packages(['base'])
4
5 # Critical packages
6 ensure_packages(['openssh', 'grub', 'sudo'])
4 7
5 # Puppet dependencies 8 # Puppet dependencies
6 ensure_packages(['git', 'puppet']) 9 ensure_packages(['git', 'puppet'])
diff --git a/modules/cron_puppet/files/post-merge b/modules/cron_puppet/files/post-merge
index 1ba08fb..ac5e3ff 100644
--- a/modules/cron_puppet/files/post-merge
+++ b/modules/cron_puppet/files/post-merge
@@ -1,7 +1,7 @@
1#!/bin/bash -e 1#!/bin/bash
2## Run Puppet locally using puppet apply 2## Run Puppet locally using puppet apply
3git submodule update --init 3git submodule update --init
4/usr/bin/puppet apply --modulepath=/etc/puppetlabs/puppet/modules /etc/puppetlabs/puppet/manifests/site.pp 4/usr/bin/puppet apply `pwd`/manifests/site.pp
5 5
6## Log status of the Puppet run 6## Log status of the Puppet run
7if [ $? -eq 0 ] 7if [ $? -eq 0 ]
diff --git a/modules/cron_puppet/manifests/init.pp b/modules/cron_puppet/manifests/init.pp
index 1756a06..c9d5a51 100644
--- a/modules/cron_puppet/manifests/init.pp
+++ b/modules/cron_puppet/manifests/init.pp
@@ -1,7 +1,9 @@
1class cron_puppet { 1class cron_puppet (
2 $code_path = "/etc/puppetlabs/code"
3) {
2 file { 'post-hook': 4 file { 'post-hook':
3 ensure => file, 5 ensure => file,
4 path => '/etc/puppetlabs/puppet/.git/hooks/post-merge', 6 path => "$code_path/.git/hooks/post-merge",
5 source => 'puppet:///modules/cron_puppet/post-merge', 7 source => 'puppet:///modules/cron_puppet/post-merge',
6 mode => '0755', 8 mode => '0755',
7 owner => root, 9 owner => root,
@@ -12,7 +14,7 @@ class cron_puppet {
12 } 14 }
13 cron { 'puppet-apply': 15 cron { 'puppet-apply':
14 ensure => present, 16 ensure => present,
15 command => "cd /etc/puppetlabs/puppet ; /usr/bin/git pull", 17 command => "cd $code_path ; /usr/bin/git pull",
16 user => root, 18 user => root,
17 minute => '*/30', 19 minute => '*/30',
18 require => File['post-hook'], 20 require => File['post-hook'],
diff --git a/modules/etckeeper/manifests/run.pp b/modules/etckeeper/manifests/run.pp
index ddbb4e1..8ff4bbf 100644
--- a/modules/etckeeper/manifests/run.pp
+++ b/modules/etckeeper/manifests/run.pp
@@ -1,7 +1,10 @@
1define etckeeper::run ($stages = [Stage['main']], $refreshonly = true, $reason = 'puppet run') { 1define etckeeper::run (
2 $refreshonly = true,
3 $reason = 'puppet run'
4) {
5
2 exec { "etckeeper::run::${name}": 6 exec { "etckeeper::run::${name}":
3 refreshonly => $refreshonly, 7 refreshonly => $refreshonly,
4 command => "/usr/bin/etckeeper commit '${reason}' || true", 8 command => "/usr/bin/etckeeper commit '${reason}' || true",
5 subscribe => $stages
6 } 9 }
7} 10}
diff --git a/modules/fail2ban b/modules/fail2ban
Subproject c1495a2c2de075863775e4ad191e0f0407fc259 Subproject c4f816ded7245641ab70d553dc27f635f07614f
diff --git a/modules/grub_install/files/config b/modules/grub_install/files/config
new file mode 100644
index 0000000..0a2ef57
--- /dev/null
+++ b/modules/grub_install/files/config
@@ -0,0 +1,47 @@
1GRUB_DEFAULT=0
2GRUB_TIMEOUT=5
3GRUB_DISTRIBUTOR="Arch"
4GRUB_CMDLINE_LINUX_DEFAULT="quiet"
5GRUB_CMDLINE_LINUX=" console=tty0 console=ttyS0,115200"
6
7# Preload both GPT and MBR modules so that they are not missed
8GRUB_PRELOAD_MODULES="part_gpt part_msdos"
9
10# Uncomment to enable Hidden Menu, and optionally hide the timeout count
11#GRUB_HIDDEN_TIMEOUT=5
12#GRUB_HIDDEN_TIMEOUT_QUIET=true
13
14# Uncomment to use basic console
15GRUB_TERMINAL_INPUT=console
16
17# Uncomment to disable graphical terminal
18#GRUB_TERMINAL_OUTPUT=console
19
20# The resolution used on graphical terminal
21# note that you can use only modes which your graphic card supports via VBE
22# you can see them in real GRUB with the command `vbeinfo'
23GRUB_GFXMODE=auto
24
25# Uncomment to allow the kernel use the same resolution used by grub
26GRUB_GFXPAYLOAD_LINUX=keep
27
28# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
29# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
30#GRUB_DISABLE_LINUX_UUID=true
31
32# Uncomment to disable generation of recovery mode menu entries
33GRUB_DISABLE_RECOVERY=true
34
35# Uncomment and set to the desired menu colors. Used by normal and wallpaper
36# modes only. Entries specified as foreground/background.
37#GRUB_COLOR_NORMAL="light-blue/black"
38#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
39
40# Uncomment one of them for the gfx desired, a image background or a gfxtheme
41#GRUB_BACKGROUND="/path/to/wallpaper"
42#GRUB_THEME="/path/to/gfxtheme"
43
44# Uncomment to get a beep at GRUB start
45#GRUB_INIT_TUNE="480 440 1"
46
47#GRUB_SAVEDEFAULT="true"
diff --git a/modules/grub_install/manifests/init.pp b/modules/grub_install/manifests/init.pp
new file mode 100644
index 0000000..172cf4b
--- /dev/null
+++ b/modules/grub_install/manifests/init.pp
@@ -0,0 +1,32 @@
1class grub_install (
2 $device = undef
3) {
4 ensure_packages(['grub'])
5
6 # unless empty($device) {
7 # exec { 'install GRUB':
8 # command => "/usr/bin/grub-install --target=i386-pc $device",
9 # subscribe => Package["grub"],
10 # }
11 # }
12
13 file_line { "/etc/default/grub#GRUB_CMDLINE_LINUX":
14 path => "/etc/default/grub",
15 line => 'GRUB_CMDLINE_LINUX=" console=tty0 console=ttyS0,115200"',
16 match => '^GRUB_CMDLINE_LINUX='
17 }
18 # file { "/etc/default/grub":
19 # ensure => "present",
20 # path => "/etc/default/grub",
21 # source => 'puppet:///modules/grub_install/config',
22 # mode => "0644",
23 # owner => "root",
24 # group => "root",
25 # # notify => [Exec["install GRUB"], Exec["update GRUB config"]]
26 # }
27
28 # exec { 'update GRUB config':
29 # command => "/usr/bin/grub-mkconfig -o /boot/grub/grub.cfg",
30 # refreshonly => true
31 # }
32}
diff --git a/modules/locales/manifests/init.pp b/modules/locales/manifests/init.pp
index 982b48e..1923f26 100644
--- a/modules/locales/manifests/init.pp
+++ b/modules/locales/manifests/init.pp
@@ -9,8 +9,4 @@ class locales {
9 subscribe => File_line['/etc/locale.gen#fr_FR.UTF-8', '/etc/locale.gen#en_US.UTF-8'], 9 subscribe => File_line['/etc/locale.gen#fr_FR.UTF-8', '/etc/locale.gen#en_US.UTF-8'],
10 refreshonly => true, 10 refreshonly => true,
11 } 11 }
12 exec { '/usr/bin/localectl set-locale LANG=fr_FR.UTF-8':
13 subscribe => File_line['/etc/locale.gen#fr_FR.UTF-8'],
14 refreshonly => true,
15 }
16} 12}