0

enter image description here

Please look into this error trying to implement the deploy.yml file with ansible plugin which is installed in the jenkins.

In ansible console I can implement the app successfully to the target machine but while same deploy.yml file using in jenkins getting error .

Tried :

  1. ssh connection from target and master machine able to connect
  2. Add the rsa key/finger print key to the target machine as well as in master controller .
  3. From terminal i can able to access target machine as well as can able to deploy any app to any VM but while switched to jenkins ansible plugin getting error.
  • I'm thinking that you're using -k which means "ask for password", which is what the error message is about. – schaiba Oct 16 '19 at 19:37
  • 1
    Why are you telling us all this, i.e what is your actual question? – Pierre.Vriens Oct 17 '19 at 5:06
  • My actual questions is : how to run ansible file in Jenkins using ansible plugin which i have already installed but still getting used that snap error . Question is that which is in snapshot error how to run . – Akshay Kumar Oct 17 '19 at 5:11
  • Hi thanks for your response but i can't find -k in any of my cmd which i have written in .yml or /hosts @schaiba – Akshay Kumar Oct 17 '19 at 5:12
  • @schaiba Got the solution : in host/inventory file which is /etc/ansible/hosts [host] 192.XXX.XXX.XXX ansible_user=ubuntu1(target hostname) ansible_become_password=XXXXXXXX(target pwd) and in .yml part we have to mentioned - hosts: host become: yes tasks: -name : Update XYZ app script: update.py (in have already written a python script for my process so i have giving same script here in .yml) – Akshay Kumar Oct 29 '19 at 19:43
3

Simple one. You should either add ansible_ssh_extra_args="-o StrictHostKeyChecking=no" to inventory or disableHostKeyChecking: true into Jenkins pipeline script (inside ansiblePlaybook block).

Like this:

ansiblePlaybook(
  colorized: true,
  installation: 'ansible27'
  inventory: '[hostsfile]'
  playbook: '[playbook]'
  disableHostKeyChecking: true
)
| improve this answer | |
  • Hi Simth , thanks i will have check and update you hope it will work as i am expecting . – Akshay Kumar Oct 17 '19 at 10:15
  • Got the solution : in host/inventory file which is /etc/ansible/hosts [host] 192.XXX.XXX.XXX ansible_user=ubuntu1(target hostname) ansible_become_password=XXXXXXXX(target pwd) and in .yml part we have to mentioned - hosts: host become: yes tasks: -name : Update XYZ app script: update.py (in have already written a python script for my process so i have giving same script here in .yml) – Akshay Kumar Oct 29 '19 at 19:43
1

Got the solution :

in the inventory file (/etc/ansible/hosts) :

[host]
192.XXX.XXX.XXX ansible_user=ubuntu1(target hostname) ansible_become_password=XXXXXXXX(target pwd)

and in the play we have to set

- hosts: host
  become: yes
  tasks:
    -name : Update XYZ app
     script: update.py

I have already written a python script for my process so I have giving same script here in .yml

| improve this answer | |
  • is that a plain-text password? :( – user2818782 Nov 1 '19 at 5:27
  • 1
    @user2818782 use that's the plain pswd which i have stored in the inventory/hosts file but you can put it in vault for the security reasons .For now i have used plain text password which is of my node/target machine not a controller . – Akshay Kumar Nov 1 '19 at 5:29
  • ah. righto. that makes sense :) – user2818782 Nov 1 '19 at 6:03
  • @user2818782 yes ,in case you are getting any error do let me know i will investigate further but for now that above method will work to push any updates to your target machine from controller . – Akshay Kumar Nov 1 '19 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.