Skip to content

Commit

Permalink
Merge pull request #4592 from svanharmelen/b-fix-chef-install
Browse files Browse the repository at this point in the history
provisioner/chef: fixes #4262
  • Loading branch information
Sander van Harmelen committed Jan 9, 2016
2 parents facd7fe + 986245c commit 05d7f2e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
13 changes: 13 additions & 0 deletions builtin/provisioners/chef/linux_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

const (
chmod = "find %s -maxdepth 1 -type f -exec /bin/chmod %d {} +"
installURL = "https://www.chef.io/chef/install.sh"
)

Expand Down Expand Up @@ -58,6 +59,9 @@ func (p *Provisioner) linuxCreateConfigFiles(
if err := p.runCommand(o, comm, "chmod 777 "+linuxConfDir); err != nil {
return err
}
if err := p.runCommand(o, comm, fmt.Sprintf(chmod, linuxConfDir, 666)); err != nil {
return err
}
}

if err := p.deployConfigFiles(o, comm, linuxConfDir); err != nil {
Expand All @@ -76,6 +80,9 @@ func (p *Provisioner) linuxCreateConfigFiles(
if err := p.runCommand(o, comm, "chmod 777 "+hintsDir); err != nil {
return err
}
if err := p.runCommand(o, comm, fmt.Sprintf(chmod, hintsDir, 666)); err != nil {
return err
}
}

if err := p.deployOhaiHints(o, comm, hintsDir); err != nil {
Expand All @@ -87,6 +94,9 @@ func (p *Provisioner) linuxCreateConfigFiles(
if err := p.runCommand(o, comm, "chmod 755 "+hintsDir); err != nil {
return err
}
if err := p.runCommand(o, comm, fmt.Sprintf(chmod, hintsDir, 600)); err != nil {
return err
}
if err := p.runCommand(o, comm, "chown -R root.root "+hintsDir); err != nil {
return err
}
Expand All @@ -98,6 +108,9 @@ func (p *Provisioner) linuxCreateConfigFiles(
if err := p.runCommand(o, comm, "chmod 755 "+linuxConfDir); err != nil {
return err
}
if err := p.runCommand(o, comm, fmt.Sprintf(chmod, linuxConfDir, 600)); err != nil {
return err
}
if err := p.runCommand(o, comm, "chown -R root.root "+linuxConfDir); err != nil {
return err
}
Expand Down
21 changes: 13 additions & 8 deletions builtin/provisioners/chef/linux_provisioner_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chef

import (
"fmt"
"path"
"testing"

Expand Down Expand Up @@ -163,14 +164,18 @@ func TestResourceProvider_linuxCreateConfigFiles(t *testing.T) {
}),

Commands: map[string]bool{
"sudo mkdir -p " + linuxConfDir: true,
"sudo chmod 777 " + linuxConfDir: true,
"sudo mkdir -p " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo chmod 777 " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo chmod 755 " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo chown -R root.root " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo chmod 755 " + linuxConfDir: true,
"sudo chown -R root.root " + linuxConfDir: true,
"sudo mkdir -p " + linuxConfDir: true,
"sudo chmod 777 " + linuxConfDir: true,
"sudo " + fmt.Sprintf(chmod, linuxConfDir, 666): true,
"sudo mkdir -p " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo chmod 777 " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo " + fmt.Sprintf(chmod, path.Join(linuxConfDir, "ohai/hints"), 666): true,
"sudo chmod 755 " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo " + fmt.Sprintf(chmod, path.Join(linuxConfDir, "ohai/hints"), 600): true,
"sudo chown -R root.root " + path.Join(linuxConfDir, "ohai/hints"): true,
"sudo chmod 755 " + linuxConfDir: true,
"sudo " + fmt.Sprintf(chmod, linuxConfDir, 600): true,
"sudo chown -R root.root " + linuxConfDir: true,
},

Uploads: map[string]string{
Expand Down

0 comments on commit 05d7f2e

Please sign in to comment.