【发布时间】:2021-10-02 06:14:47
【问题描述】:
#/etc/puppetlabs/code/environments/production/modules/mymodule/manifests/init.pp
class mymodule {
file { "/bin/extend_shutdown.sh":
mode => "0644",
owner => 'root',
group => 'root',
source => 'puppet:///modules/mymodule/extend_shutdown.sh',
}
file { "/bin/server_shutdown.sh":
mode =>"777",
owner =>'root',
group => 'root',
source => 'puppet:///modules/mymodule/server_shutdown.sh',
}
file { "/bin/user_activity.sh":
mode =>"777",
owner =>'root',
group => 'root',
source => 'puppet:///modules/mymodule/user_activity.sh',
}
file { "/bin/new_cron.sh":
mode =>"777",
owner =>'root',
group =>'root',
source => 'puppet:///modules/mymodule/new_cron.sh',
}
file { "/home/azureuser/shutdown.sh":
mode =>"777",
owner =>'root',
group =>'root',
source => 'puppet:///modules/mymodule/shutdown.sh',
}
file { "/bin/tag.sh":
mode => "777",
owner => 'root',
group => 'root',
source =>'puppet:///modules/mymodule/tag.sh',
}
#file { "/etc/profile":
#mode => "777",
#owner => 'root',
# group => 'root',
# source =>'puppet:///modules/mymodule/profile',
# }
file { "/etc/.bash_aliases":
mode => "777",
owner => 'root',
group => 'root',
source =>'puppet:///modules/mymodule/.bash_aliases',
}
#file { "/etc/profile.d/alias.sh":
# mode => "777",
# owner =>'root',
# group =>'root',
# source => 'puppet:///modules/mymodule/alias.sh',
# }
file { "/bin/max_timetrack.sh":
mode => "777",
owner =>'root',
group => 'root',
source => 'puppet:///modules/mymodule/max_timetrack.sh',
}
}
#azureuser@disk-bkp:/rescue/etc/puppetlabs/code/environments/production/manifests$ cat site.pp
node default {
include mymodule
cron {'user_tracking':
ensure => 'present',
command => 'bash /bin/user_activity.sh',
hour => ['*'],
minute => ['30'],
user => 'root',
}
#cron {'shutdown1':
# ensure =>'present',
# command => 'bash /bin/server_shutdown.sh',
# hour => ['*'],
# minute => ['*/15'],
# user => 'azureuser',
#}
cron {'new_cron':
ensure => 'present',
command => 'bash /bin/new_cron.sh',
hour => ['*'],
minute => ['*'],
user => 'root',
}
exec {'shutdown_running_status':
command => 'cat /var/log/syslog | grep server_shutdown.sh',
provider => shell,
}
exec { 'reconfigure_cron':
command => 'bash /home/azureuser/test.sh',
provider => shell,
}
exec {'input.log':
command => 'user=`whoami`;sudo touch /usr/bin/input_${user}.log ; sudo chmod 777 /usr/bin/input_${user}.log',
provider => shell,
}
exec {'profile':
command => 'echo "source /etc/.bash_aliases" >> /etc/bash.bashrc',
path => [ '/bin', '/sbin' , '/usr/bin', '/usr/sbin' ],
provider => 'shell',
unless => 'cat /etc/bash.bashrc |grep -i /etc/.bash_aliases',
}
exec {'getting_tag':
command => 'sudo bash /bin/tag.sh',
path => [ '/bin', '/sbin' , '/usr/bin', '/usr/sbin' ],
provider => 'shell',
}
exec {'folder_creation':
command => 'sudo mkdir /pg',
path => [ '/bin', '/sbin' , '/usr/bin', '/usr/sbin' ],
provider => 'shell',
unless => 'ls -ld /pg',
}
exec {'deleting_log_file':
command => 'sudo cd /pg/; sudo rm *',
path => [ '/bin', '/sbin' , '/usr/bin', '/usr/sbin' ],
provider => 'shell',
}
}
在客户端机器上执行puppet agent --test 后,客户端和主服务器可以正常工作一到两个小时,然后它们就会中断。看起来/bin 文件夹正在被删除。我收到此错误:
错误:ubuntu@18.222.8.217:权限被拒绝(公钥)
我在多台机器上尝试过相同的代码,但所有机器都处于相同状态。我的代码有什么问题?
【问题讨论】:
标签: puppet