Comments (9)
@MasteringBOX I made it work, it was issue on my side with SSH keys and config. After generating new SSH keypair and setting parameters correctly:
- name: deploy stuff
uses: dawidd6/action-ansible-playbook@v2
with:
playbook: deploy.yaml
key: ${{ secrets.SSH_KEY }}
options: |
--user ssh_user
--ssh-extra-args "-o StrictHostKeyChecking=no"
and setting --ssh-extra-args "-o StrictHostKeyChecking=no"
GH action was able to connect to machines successfully.
from action-ansible-playbook.
@vardumper agree it would be nice to have some documentation advising against setting the ansible_ssh_private_key_file value in the README. I'm not the best at node.js but it looks like the key is copied to a file called ".ansible_key" so you might be able to set ansible_ssh_private_key_file to that but easier to just omit it.
if (key) {
const keyFile = ".ansible_key"
fs.writeFileSync(keyFile, key + os.EOL, { mode: 0600 })
core.saveState("keyFile", keyFile)
cmd.push("--key-file")
cmd.push(keyFile)
}
from action-ansible-playbook.
EDIT: I solved it
I can't connect :/ I tried both suggestions and I got a permission denied error. I stored the private key string in an action secret and added it to the "key" variable. Is there anything I'm missing?
name: Deploy
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
deploy_code:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run Ansible playbook
uses: dawidd6/[email protected]
with:
playbook: ansible/deploy.yml
key: ${{secrets.ANSIBLE_PRIVATE_KEY}}
inventory: |
[exampleserver]
example ansible_host=example.com ip=55.555.55.55 ansible_port=5555 ansible_ssh_user=example
from action-ansible-playbook.
EDIT: I solved it
@MasteringBOX could you please elaborate more how you have fixed this? I'm facing the similar issue, looks like action is ignoring the value of key
parameter.
from action-ansible-playbook.
Hi @jozef-valko,
I don't fully remember, it was something silly.
Try adding your key to a secret called exactly SECRET_SSH_KEY.
I was using
key: ${{secrets.ANSIBLE_PRIVATE_KEY}}
and while I was desperately trying things I added the key to a new secret called SECRET_SSH_KEY and it worked.
So try creating that action secret with your secret key contents and changing the key value to:
key: ${{secrets.SECRET_SSH_KEY}}
But it may have been something else. Let me know if that works!
By the way, after configuring this I ended up using Github actions directly, they are pretty straightforward and they will deploy faster.
from action-ansible-playbook.
Don't forget to set the ssh user
from action-ansible-playbook.
I will gladly review PRs improving the documentation.
from action-ansible-playbook.
Always getting this error
This is my workflow
from action-ansible-playbook.
Solved this issue by creating a self hosted runner
from action-ansible-playbook.
Related Issues (20)
- Deprecation of "save-state" and "set-output" HOT 3
- NodeJS 12 is depreciated in GitHub Actions
- save-state command is depreciated warning HOT 3
- Feature request: ansible-galaxy install force flag HOT 2
- SSH Tunneling Bastion HOT 2
- Ansible Galaxy : command not found HOT 2
- Error on windows-latest runner HOT 2
- Missing playbook HOT 6
- Ensure SSH private key uses LF and not CRLF HOT 4
- ansible-playbook not found on private runner HOT 1
- private key permission problem HOT 1
- How to pass multiple extra variables? HOT 1
- Galaxy SSH configuration? HOT 4
- extra_vars option: json format: string "true" turned into boolean "true" HOT 4
- make action fail if no hosts were updated HOT 1
- make separate location for ansible vault file possible HOT 2
- Node16 deprecated HOT 2
- vault_password not being set? HOT 1
- Ansible inventory requires additional Python packages HOT 1
- Playbook keeps failing when using GA HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from action-ansible-playbook.