config/system: add shell user attribute

This adds support for specifying the login shell of created users.
This commit is contained in:
Richard Marshall 2015-03-06 14:16:19 -08:00
parent 66a2f00679
commit f5ecc05d62
3 changed files with 10 additions and 0 deletions

View File

@ -374,6 +374,7 @@ users:
no_user_group: true
system: y
no_log_init: True
shell: /bin/sh
`
cfg, err := NewCloudConfig(contents)
if err != nil {
@ -441,6 +442,10 @@ users:
if !user.NoLogInit {
t.Errorf("Failed to parse no_log_init field")
}
if user.Shell != "/bin/sh" {
t.Errorf("Failed to parse shell field, got %q", user.Shell)
}
}
func TestCloudConfigUsersGithubUser(t *testing.T) {

View File

@ -29,4 +29,5 @@ type User struct {
NoUserGroup bool `yaml:"no_user_group"`
System bool `yaml:"system"`
NoLogInit bool `yaml:"no_log_init"`
Shell string `yaml:"shell"`
}

View File

@ -72,6 +72,10 @@ func CreateUser(u *config.User) error {
args = append(args, "--no-log-init")
}
if u.Shell != "" {
args = append(args, "--shell", u.Shell)
}
args = append(args, u.Name)
output, err := exec.Command("useradd", args...).CombinedOutput()