8401470b13f220e289c788eb730e14566912ea8f
[bottlenecks.git] / testsuites / rubbos / puppet_manifests / modules / rubbos_mysql / manifests / rubbos_mysql_off.pp
1 #############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10
11 class rubbos_mysql::rubbos_mysql_off {
12
13   include params::rubbos_params
14
15   # Declare some variables
16   $rubbos_app_tools     = $params::rubbos_params::rubbos_app_tools
17   $mysql_user_group     = $params::rubbos_params::mysql_user_group
18   $mysql_user_name      = $params::rubbos_params::mysql_user_name
19   $mysql_user_password  = $params::rubbos_params::mysql_user_password
20
21   file {'${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64.tar.gz':
22         path    => "${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64.tar.gz",
23         ensure  => absent,
24         backup  => false,
25   }
26
27   # Stop mysql
28   service {'stop mysql':
29         ensure          => stopped,
30         hasstatus       => false,
31         provider        => "upstart",
32         status          => "${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64/support-files/mysql.server status | grep 'MySQL running'",
33         start           => "${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64/bin/mysqld_safe &",
34         stop            => "${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64/bin/mysqladmin shutdown",
35   }
36
37   file {'${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64':
38         ensure  => absent,
39         path    => "${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64",
40         force   => true,
41         recurse => true,
42         backup  => false,
43         require => Service['stop mysql'],
44   }
45
46   # Remove user and group
47   user {'${mysql_user_name}':
48         name            => "${mysql_user_name}",
49         ensure          => absent,
50         groups          => "${mysql_user_group}",
51         password        => "${mysql_user_password}",
52         require         => File['${rubbos_app_tools}/mysql-5.5.46-linux2.6-x86_64'],
53   }
54
55   group {'${mysql_user_group}':
56         name    => "${mysql_user_group}",
57         ensure  => absent,
58         require => User['${mysql_user_name}'],
59   }
60
61   # Remove softlink
62   exec {'rm -rf /usr/local/mysql':
63         cwd     => "/usr/local",
64         command => "rm -rf /usr/local/mysql",
65         onlyif  => "test -h /usr/local/mysql",
66         path    => ["/bin","/sbin","/usr/bin","/usr/sbin","/usr/local/bin","/usr/local/sbin"],
67         require => Group['mysql'],
68   }
69
70   # Remove packages
71   package {'libaio-dev':
72         ensure  => absent,
73   }
74   package {'libaio1':
75         ensure  => absent,
76   }
77
78 }