ansible-inventory

Custom credentials in Ansible Tower with Custom Python Script

房东的猫 提交于 2019-12-23 00:09:20
问题 I'm trying to implement a custom script in Ansible Tower to dynamically import an inventory. The custom script is basically written using Python and is interacting with a Windows 2012 Server which is acting as a domain controller (DC). When the script is executed from Ansible Tower, it pulls all the workstations from the DC and adds to the Ansible inventory. In doing so, I had to pass DC's login credentials in the Python script as a plain text, which is not desired. Hence was looking if there

ansible returns with "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))

被刻印的时光 ゝ 提交于 2019-12-20 05:53:56
问题 I am running myserver in ubuntu: + sudo cat /etc/os-release NAME="Ubuntu" VERSION="16.04.6 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.6 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial I use ansible and when I run it I get the following error: fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the

accessing inventory host variable in ansible playbook

廉价感情. 提交于 2019-12-20 03:01:04
问题 I am using ansible 2.1. I have the following inventory host file and a role being called by a play that needs access to the host file variable. Any thoughts on how to access it (currently getting an error): host file [test1] test-1 ansible_ssh_host=abc.def.ghi.jkl ansible_ssh_port=1212 [test2] test2-1 ansible_ssh_host=abc.def.ghi.mno ansible_ssh_port=1212 [test3] test3-1 ansible_ssh_host=abc.def.ghi.pqr ansible_ssh_port=1212 test3-2 ansible_ssh_host=abc.def.ghi.stu ansible_ssh_port=1212 [all

Multistage deployment with ansible

独自空忆成欢 提交于 2019-12-18 11:36:07
问题 What approach would you advise to organize multistage deployment with Ansible in case you have different variables for stages? The main idea is defining group variables for different stages. There are two articles: http://rosstuck.com/multistage-environments-with-ansible/ http://toja.io/using-host-and-group-vars-files-in-ansible/ I'd like to get more examples about organizing playbooks, variables, and hosts, and understand advantages and disadvantages of your approach. 回答1: Recently, I used

How Exactly Does Ansible Parse Boolean Variables?

拟墨画扇 提交于 2019-12-18 03:07:11
问题 In Ansible, there are several places where variables can be defined: in the inventory, in a playbook, in variable files, etc. Can anyone explain the following observations that I have made? When defining a Boolean variable in an inventory, it MUST be capitalized (i.e., True/False), otherwise (i.e., true/false) it will not be interpreted as a Boolean but as a String. In any of the YAML formatted files (playbooks, roles, etc.) both True/False and true/false are interpreted as Booleans. For

Ansible, how to define a list in host inventory?

北城以北 提交于 2019-12-13 21:31:11
问题 I have a playbook and I want to define a list of strings in my hosts file. Here's my host file: [dashboard] 1.2.3.4 dashboard_domain=test site_domain=['one','two','foo', 'bar'] Here's my playbook that I attempted to write using the list documentation: --- - hosts: dashboard gather_facts: False remote_user: ubuntu become: yes tasks: - name: ping ping: - debug: msg: "Domain: {{dashboard_domain}}" - debug: msg: "Site: {{ item }}" with_items: "{{site_domain}}" However running this playbook with

ansible - define hosts/tag from dynamic inventory in the host file

五迷三道 提交于 2019-12-12 04:36:26
问题 I am using ec2.py and specific tag on ec2 instances to get my hosts, the results are shown as list of IP addresses, for example: The results from ec2.py: "tag_test_staging": [ "10_80_20_47" ], I define the tag in my playbook - hosts: tag_Name_test and it is run on all the instances with tag_Name_test . Is there a way to define the hosts/tag in the hosts file under the inventory/ folder and the playbook will take the hosts from there instead of specify the ec2 tag directly on the playbook like

Accessing host variables in tasks in Ansible

半腔热情 提交于 2019-12-11 11:01:48
问题 I have a host group which have host variables as shown below [test:children] test1 test2 test3 [test:vars] clean_images=true I have a tasks defined in a role as shown below - name: clean docker images template: dest: "/etc/systemd/system/{{ item.name }}" with_items: - { name: "{{ service_name }}.service" } - name: start service systemd: name: "{{ service_name }}.service" state: started enabled: yes when: hostvars['test'].clean_images is defined This is a simple tasks, where I clean docker

How to add multiple inventory files in command line while executing a playbook

孤者浪人 提交于 2019-12-11 00:21:46
问题 I am having a playbook with two different plays Sample.yml - name : Play1 hosts: Host1 tasks: ... - name: Play2 hosts: Host2 tasks: ... I need to run this playbook with two different hosts( Host1 and Host2 ) and these two different hosts are present in two separate files( Hostfile1 and Hostfile2 ) under inventory/ directory. inventory/ Hostfile1 Hostfile2 . . HostfileN I want to know how to include two different hosts file while running the playbook. I know by including the entire folder (

ansible variables shared with multiple groups if inventory is only localhost

旧时模样 提交于 2019-12-10 22:24:45
问题 I use ansible to send jobs / configurations to my k8s cluster via the kubectl command on my local machine. I have my inventory file setup so that each cluster is it's own group and each cluster is basically a connection to localhost . # Inventory File # [east.k.example.com] localhost ansible_connection=local [east2.k.example.com] localhost ansible_connection=local Then in my group_vars directory I have a different file with the name of my group from my inventory file that holds all the