流浪汉+傀儡:找不到部署命令后执行脚本



我正在尝试在使用Vagrant + Puppet部署后执行脚本:

  include nginx
  $nginx_conf_path = "${files_path}/${fqdn}/etc/nginx/sites-available"
  nginx::site { 'test.example.com.conf' :
    source => "${nginx_conf_path}/test.example.com.conf",
  }
  exec { 'install-letsencrypt.sh test.example.com':
    require => [Nginx::Site['test.example.com.conf'], Class['profile::ssl']],
    command => 'install-letsencrypt.sh test.example.com',
    path    => '/home/vagrant/bin/'
  }

ssl.pp

class profile::ssl { 
  file { "/home/vagrant/bin" :
    ensure => "directory",
    owner  => "vagrant",
    group  => "vagrant",
  }
  file { "/home/vagrant/bin/install-letsencrypt.sh":
    ensure => "present",
    owner  => "vagrant",
    group  => "vagrant",
    mode => 700,
    source => "puppet:///modules/example/shared/install-letsencrypt.sh"
  }
}

install-letsencrypt.sh

if [ ! -d "/opt/letsencrypt" ]; then
  sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
fi
# ...etc

profile::ssl工作是因为/home/vagrant/bin/install-letsencrypt.sh可用,但是当我尝试在木偶中exec它时,我得到:

==> test.example.com: Error: Deploying Let's encrypt for test.mojjo.fr
==> test.example.com: /home/vagrant/bin/install-letsencrypt.sh: line 11: sudo: command not found
==> test.example.com: /home/vagrant/bin/install-letsencrypt.sh: line 14: mkdir: command not found
==> test.example.com: /home/vagrant/bin/install-letsencrypt.sh: line 17: sudo: command not found
==> test.example.com: /home/vagrant/bin/install-letsencrypt.sh: line 23: sudo: command not found
==> test.example.com: /home/vagrant/bin/install-letsencrypt.sh: line 25: sudo: command not found

我做错了什么?我尝试使用绝对可执行路径(/usr/bin/sudo而不是sudo),但它也不起作用。如果我ssh test.example.com并在那里运行它,它也可以工作,所以问题不在脚本中。

提前致谢

我在运行一些脚本时遇到了同样的问题,所以我做了

  exec { 'run-script':
    command => "bash -c 'install-letsencrypt.sh test.example.com'",
    ....
  }

最新更新