chef-infra - Chef 不为用户创建主目录

标签 chef-infra chef-recipe chef-solo test-kitchen

我有一个 Chef Recipe 来创建部署用户。运行 kitchen converge 时正在创建用户。尝试为用户创建 .ssh 文件夹时失败,因为用户的主目录不存在。 父目录/home/deploy 不存在,无法创建/home/deploy/.ssh

cookbooks/main/recipes/user.rb

user deploy do
  action :create
  comment 'Application deploy user'
  home "/home/#{node['deploy_user']}"
  shell '/bin/bash'
  system true
  supports manage_home: true
end

directory "/home/#{node['deploy_user']}/.ssh" do
  mode 0700
  owner node['deploy_user']
  group node['deploy_user']
end

template "/home/#{node['deploy_user']}/.ssh/authorized_keys" do
  mode 0600
  owner node['deploy_user']
  source 'authorized_keys.erb'
end

.厨房.yml

---
driver:
  name: vagrant

provisioner:
  name: chef_solo

platforms:
  - name: ubuntu-14.04
  - name: centos-7.1

suites:
  - name: default
    run_list:
      - recipe[main::default]
    attributes:

最佳答案

这也激怒了我。 Chef 没有理由不让如此简单的日常操作变得容易执行。

由于这是一个热门的谷歌搜索,我不清楚其他答案是否正确,这正是我需要运行才能让它工作的东西。我正在使用 Chef 服务器 12.4 和客户端 12.10.24。全部在 Ubuntu 14.04 上。

user '<USERNAME>' do
  gid '<MY_GROUP_NAME>'
  shell '/bin/bash'
  comment 'some stuff i want to say'
  home "/home/<USERNAME>"
  supports manage_home: true
  action :create
end

我的/etc/login.defs 文件是未修改的默认值。

关于chef-infra - Chef 不为用户创建主目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34619583/

相关文章:

linux - Chef 推荐的执行命令的方式

ruby - 在 Chef 资源之间传递变量

mysql - 如果我 include_recipe "database::mysql",我可以使用 mysql_database 资源吗?

使用 Chef 在 CentOS 上安装 MySQL 社区服务器

ruby-on-rails - 我需要学习什么来管理服务器/部署?

java - 在 Chef 中禁用 docker 容器日志配置

chef-infra - CHEF,如何替换 Chef Solo 中的 node.set/node.save ?

chef-infra - Chef knife create 无法创建 API 用户

chef-infra - 随机打乱给定的列表?

ruby - Chef - 使用同一本 Recipe 中的 Recipe