0

I want to fetch my RoR code from git, build it and then push it to multiple remote machine through Ansible script. I have mentioned my all machine details under hosts file of Ansible.

I have created the ssh key and pushed it under ssh key section of my github account. Here is my playbook.yml looks like.

---
- hosts: ansibleserver
  tasks:
    - git:
        repo: git@github.com:abc/abc.git
        dest: /tmp/LMS/
        version: master
        key_file: /root/.ssh/id_rsa
- hosts: redisservers
  tasks:
    - name: Copy file to a remote server
      copy:
        src: /root/LMS/
        dest: /root/LMS/
- hosts: webservers
  user: root
  vars:
      user: root
      home_directory: "/root/LMS/app/"
      rails_env: "development"
      deploy_to: "{{ /root/LMS/ }}"
~

I am unable to execute a single task, below are the errors.

PLAY [ansibleserver] ***************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************
fatal: [192.168.193.30]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: \\S\nKernel \\r on an \\m\n                                    !!!WARNING!!!                   \n############################################################################\nACCESS TO THIS SYSTEM IS STRICTLY RESTRICTED TO AUTHORIZED PERSONS ONLY \nUNAUTHORIZED ACCESS TO THIS SYSTEM IS NOT ALLOWED AND EVERY ACTIVITY IS MONITORED ON THIS \n                                      SYSTEM.                                \t\t\n###########################################################################################\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).", "unreachable": true}

PLAY RECAP *************************************************************************************************************************************************************
192.168.193.30             : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0

Since it fails at very first task, unable to move to 2nd and third one.

Asad Ali
  • 389
  • 1
  • 10
  • 28
  • Wait... that is no longer what you asked?! Can you first mark this question (in its original form) resolved? Then you can ask a new one, with the new error message. – VonC Jul 08 '19 at 11:36
  • Again, this is a different question: make a new one. My answer was for your original question. – VonC Jul 09 '19 at 06:01

1 Answers1

0

Check first if this not a YAML syntax issue:

  - git: Cloning LMS code from git
      repo: git@github.com:**/abc.git
      dest: /root/deployer/setup/abc/
      version: master

Meaning: the Git module should have its options indented compared to Git itself.
See the examples:

# Example git checkout from Ansible Playbooks
- git:
    repo: 'https://foosball.example.org/path/to/repo.git'
    dest: /srv/checkout
    version: release-0.22
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250