Ansible Deploy for Bamboo

Description

A simple addon introducing support for ansible execution directly from your deploy and build projects

​Main features:


  • support for main commands ansible and ansible-playbook



  •  automatic cleanup of child processes from ansible





In order to use the plugin you will need to install ansible of the agent and ensure it is in the system path.

Global settings under addon configuration is allowing you to change generic settings, customizable variables and filter environments where custom deployment is allowed.




















In order to trigger a custom deployment use Ansible deployment from main menu. This will allow you to choose hosts/tags that will be used by the Ansible playbook run.





Initially the hosts and tags lists will be empty but after the first run  things should get populated.


Note: the plugin will be using regular output and parse it in order to gather HOSTS and TAGS. If this output has been formatted using some callback please provide a sample and we will include it in the plugin for parsing.

19 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Why is it not using the ssh key from the user running bamboo? Is there a way to use key authentication without providing it in the task?

    ReplyDelete
    Replies

    1. I never provide the keys inside bamboo plugin. I only specify in inventory the servers and keys like ~/.ssh/xsa.pem or just server address

      Also make sure the bamboo agent user is trusted by remote server.

      Delete
    2. The bamboo agent user is trusted by remote server, but it seams that the way ansible gets called from bamboo the key in my case ~/.ssh/id_ecdsa is not used, when I login as the bamboo agent user and ssh to the remote server I can login with the ssh key.

      Delete
    3. My bad, as usual the problem sits in front of the pc, after going through with -vvvv I got the problem, I forgot to set the remote_user to root.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi, there. I uploaded the PEM via the task, public key has been deployed to the target server, but I'm still getting the ERROR 13(host key cannot be verified)

    ReplyDelete
    Replies
    1. Try to add -vvvv to the options of the ansible deploy task to see more information. I would check few things like: permissions of the authorized_keys, enabled key types on the server (like is rsa, dsa enabled depending on your key) etc. The flag -vvvv should give more info about what is wrong.

      Delete
    2. Thanks! I got it working with the default ssh key, id_rsa....what if i have a different key pair with name like "ansible", how can I specify the task to use this key?

      Delete
    3. I put in inventory something like this:

      [bastionhosts]
      1.1.1.1 ansible_ssh_private_key_file=~/.ssh/bastion.pem ansible_ssh_user=ec2-user

      Delete
    4. Anonymous3/26/2018

      Thanks a lot... I will give it a try

      Delete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. I'm a little confused on how to use this. I have a playbook already written - do I have to copy and paste it's contents into the configuration of the task or can I just reference the playbook through this task?

    ReplyDelete
    Replies
    1. Also, if I can use a playbook on the agent's filesystem (or pull one down from Bitbucket), where does that path go?

      Delete
    2. you can just reference the file. the adhoc playbook is just a separate capability so you can write playbooks in bamboo, just make sure only one is used, filename or inline.

      Delete
    3. Ok thanks. When I try to add an Ansible Playbook task to a deploy job I get the nasty red message at the top:

      No agents meet the Environments's requirements.

      What do I need to add so the agent knows it can run this? Sorry for the newbie questions - I'm totally new to CI/CD and am on the Infrastructure team ;)

      Delete
    4. the system should have ansible installed and available in the path so capability can be detected.

      Delete
  7. Will the plugin supports Ansible Tower?

    ReplyDelete
    Replies
    1. The plugin is not using Tower at the moment, do you see any benefits of this integration ? We can think about it as a feature request and see where it leads :)

      Delete