@@ -20,21 +20,21 @@ func New(processFactory process.Factory) *Ansible {
2020 }
2121}
2222
23- func (i * Ansible ) Install (osName , sudoPassword string ) (err error ) {
23+ func (ansible * Ansible ) Install (osName , sudoPassword string ) (err error ) {
2424 var installed bool
2525
26- if installed , err = i .isInstalled (); nil != err {
26+ if installed , err = ansible .isInstalled (); nil != err {
2727 return err
2828 }
2929
3030 if false == installed {
3131 switch osName {
3232 case "oracle-linux" :
3333 processes := []* process.Process {
34- i .processFactory .NewSudoProcess (sudoPassword , "dnf" , "check-update" , "-y" ),
35- i .processFactory .NewSudoProcess (sudoPassword , "dnf" , "upgrade" , "-y" ),
36- i .processFactory .NewSudoProcess (sudoPassword , "dnf" , "install" , "-y" , "epel-release" ),
37- i .processFactory .NewSudoProcess (sudoPassword , "dnf" , "install" , "-y" , "ansible" ),
34+ ansible .processFactory .NewSudoProcess (sudoPassword , "dnf" , "check-update" , "-y" ),
35+ ansible .processFactory .NewSudoProcess (sudoPassword , "dnf" , "upgrade" , "-y" ),
36+ ansible .processFactory .NewSudoProcess (sudoPassword , "dnf" , "install" , "-y" , "epel-release" ),
37+ ansible .processFactory .NewSudoProcess (sudoPassword , "dnf" , "install" , "-y" , "ansible" ),
3838 }
3939
4040 terminal .Printf ("\n <comment>$ %s</comment>\n " , processes [0 ].String ())
@@ -67,8 +67,8 @@ func (i *Ansible) Install(osName, sudoPassword string) (err error) {
6767 return nil
6868}
6969
70- func (i * Ansible ) RunAnsiblePlaybook (playbookFilePath , variableFilePath , sudoPassword string ) (err error ) {
71- proc := i .processFactory .NewProcess (
70+ func (ansible * Ansible ) RunAnsiblePlaybook (playbookFilePath , variableFilePath , sudoPassword string , args ... string ) (err error ) {
71+ proc := ansible .processFactory .NewProcess (
7272 "HISTSIZE=0" ,
7373 "ansible-playbook" ,
7474 playbookFilePath ,
@@ -81,6 +81,10 @@ func (i *Ansible) RunAnsiblePlaybook(playbookFilePath, variableFilePath, sudoPas
8181 proc .AddArguments ("-" + strings .Repeat ("v" , terminal .GetLogLevel ()- 1 ))
8282 }
8383
84+ if len (args ) > 0 {
85+ proc .AddArguments (args ... )
86+ }
87+
8488 terminal .Printf ("\n <comment>$ %s</comment>\n " , proc .String ())
8589 if _ , err = proc .Run (); nil != err {
8690 return err
@@ -89,17 +93,17 @@ func (i *Ansible) RunAnsiblePlaybook(playbookFilePath, variableFilePath, sudoPas
8993 return nil
9094}
9195
92- func (i * Ansible ) isInstalled () (installed bool , err error ) {
96+ func (ansible * Ansible ) isInstalled () (installed bool , err error ) {
9397 var path string
9498 var realPath string
9599
96- if path , err = i .processFactory .NewProcess ("which" , "ansible" ).Output (); nil != err && "exit status 1" != err .Error () {
100+ if path , err = ansible .processFactory .NewProcess ("which" , "ansible" ).Output (); nil != err && "exit status 1" != err .Error () {
97101 return false , err
98102 }
99103 path = strings .TrimSpace (path )
100104
101105 if "" != path {
102- if realPath , err = i .processFactory .NewProcess ("ls" , path ).Output (); nil != err {
106+ if realPath , err = ansible .processFactory .NewProcess ("ls" , path ).Output (); nil != err {
103107 return false , err
104108 }
105109
0 commit comments