Giter Club home page Giter Club logo

Comments (9)

jozef-valko avatar jozef-valko commented on July 20, 2024 1

@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.

clincha avatar clincha commented on July 20, 2024

@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.

MasteringBOX avatar MasteringBOX commented on July 20, 2024

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.

jozef-valko avatar jozef-valko commented on July 20, 2024

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.

MasteringBOX avatar MasteringBOX commented on July 20, 2024

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.

port19x avatar port19x commented on July 20, 2024

Don't forget to set the ssh user

from action-ansible-playbook.

dawidd6 avatar dawidd6 commented on July 20, 2024

I will gladly review PRs improving the documentation.

from action-ansible-playbook.

arnabnath180 avatar arnabnath180 commented on July 20, 2024

Screenshot from 2024-01-21 11-46-00
Always getting this error
This is my workflow
Screenshot from 2024-01-21 12-48-40

from action-ansible-playbook.

arnabnath180 avatar arnabnath180 commented on July 20, 2024

Solved this issue by creating a self hosted runner

from action-ansible-playbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.