File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ inputs:
1616 key :
1717 description : SSH private key used to connect to the host
1818 required : false
19+ private-key :
20+ description : SSH private key used to connect to the host
21+ required : false
1922 inventory :
2023 description : Custom content to write into hosts
2124 required : false
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ async function main() {
1010 const requirements = core . getInput ( "requirements" )
1111 const directory = core . getInput ( "directory" )
1212 const key = core . getInput ( "key" )
13+ const private_key = core . getInput ( "private-key" )
1314 const inventory = core . getInput ( "inventory" )
1415 const vaultPassword = core . getInput ( "vault_password" )
1516 const knownHosts = core . getInput ( "known_hosts" )
@@ -50,6 +51,14 @@ async function main() {
5051 cmd . push ( keyFile )
5152 }
5253
54+ if ( private_key ) {
55+ const privateKeyFile = ".ansible_key"
56+ fs . writeFileSync ( privateKeyFile , private_key + os . EOL , { mode : 0600 } )
57+ core . saveState ( "privateKeyFile" , privateKeyFile )
58+ cmd . push ( "--private-key" )
59+ cmd . push ( privateKeyFile )
60+ }
61+
5362 if ( inventory ) {
5463 const inventoryFile = ".ansible_inventory"
5564 fs . writeFileSync ( inventoryFile , inventory , { mode : 0600 } )
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ async function main() {
1212 try {
1313 const directory = core . getState ( "directory" )
1414 const keyFile = core . getState ( "keyFile" )
15+ const privateKeyFile = core . getState ( "privateKeyFile" )
1516 const inventoryFile = core . getState ( "inventoryFile" )
1617 const vaultPasswordFile = core . getState ( "vaultPasswordFile" )
1718 const knownHostsFile = core . getState ( "knownHostsFile" )
@@ -22,6 +23,9 @@ async function main() {
2223 if ( keyFile )
2324 rm ( keyFile )
2425
26+ if ( privateKeyFile )
27+ rm ( privateKeyFile )
28+
2529 if ( inventoryFile )
2630 rm ( inventoryFile )
2731
You can’t perform that action at this time.
0 commit comments