0
votes

I want to build an automatic deploy job for a remote git repository in jenkins which only contains a config file with playbook same syntax. Using ansible-galaxy I install necessary roles in the working directory. But I did not know what to do for inventory files and host variables.

I thought it would be good if I build an ansible role containing our local servers inventory files and host_Vars folder. So by installing that role on the ansible slave working directory and passing inventory name as an argument I could copy files related to that name in the ansible folder and use it in the next step as inventory files and vars for deploying on remote server.

First of all, does anyone has a better Idea for making an inventory file on the fly? Using local git server and repositories or shell commands?

Main question : How to copy those file from a role to the very same directory of ansible? (it would be copied into ../.. directory of files.)

1

1 Answers

0
votes
  1. You can use ansible-playbook -i 10.0.0.0, /var/lib/jenkins/somerole/main.yml -e "some_var=xxx"
  2. Ansible dynamic inventory: ansible -i openstack.py all -m ping

I want to build an automatic deploy job for a remote git repository in jenkins which only contains a config file with playbook same syntax.

  • Variables Defined in Inventory
  • As of Ansible 1.3, extra vars can be loaded from a JSON/YAML file with the @ syntax:

    --extra-vars "@some_file.json" Also as of Ansible 1.3, extra vars can be formatted as YAML, either on the command line or in a file as above.