ansible

Ansible aclling two diffrent file variables into single task looping through multiple files

戏子无情 提交于 2020-07-21 05:54:25
问题 Content of fil1 # cat file1 fostrain01.example.com fostrain02.example.com fostrain03.example.com Content of file2 # cat fil2 ServerIPS 171.20.20.16 171.20.20.17 171.20.20.18 171.20.20.19 171.20.20.20 ServerIPS 171.20.20.21 171.20.20.22 171.20.20.23 171.20.20.24 171.20.20.25 In the below playbook, its replacing the contents on two lines one is hostname as str and in another line replacing the ip So, i have taken the two different task 1) Replace strings in file & 2) Replace ip in file to

Ansible: using nested groups with vars

浪子不回头ぞ 提交于 2020-07-19 06:15:32
问题 I have a situation where we have 3 tiers of boxes, in each tier we apply different variables settings (like where the cache dir is), but there are a bunch of defaults. I also need to override on a per node basis, which is usually done via inventory vars on the host itself. I am not sure what is the best way to organize the hosts so that the precedence works in my favor. Here are the different things I have tried. In each case I have entries in the inventory file like this: [bots-fancy] fancy

Ansible: using nested groups with vars

情到浓时终转凉″ 提交于 2020-07-19 06:14:54
问题 I have a situation where we have 3 tiers of boxes, in each tier we apply different variables settings (like where the cache dir is), but there are a bunch of defaults. I also need to override on a per node basis, which is usually done via inventory vars on the host itself. I am not sure what is the best way to organize the hosts so that the precedence works in my favor. Here are the different things I have tried. In each case I have entries in the inventory file like this: [bots-fancy] fancy

Ansible: using nested groups with vars

徘徊边缘 提交于 2020-07-19 06:14:11
问题 I have a situation where we have 3 tiers of boxes, in each tier we apply different variables settings (like where the cache dir is), but there are a bunch of defaults. I also need to override on a per node basis, which is usually done via inventory vars on the host itself. I am not sure what is the best way to organize the hosts so that the precedence works in my favor. Here are the different things I have tried. In each case I have entries in the inventory file like this: [bots-fancy] fancy

Ansible stdout Formatting

谁说我不能喝 提交于 2020-07-17 10:44:45
问题 Assuming the below tasks: shell: "some_script.sh" register: "some_script_result" debug: msg: "Output: {{ some_script_result.stdout_lines }} I receive the below output: "msg": "Output: [u'some_value',u'some_value2,u'some_value3]" How do I get the output to print as? "msg": Output: some_value some_value2 some_value3 Ansible version is 2.4.2. Thank you! 回答1: Try this option. You’ll love it. There's a new YAML callback plugin introduced with Ansible 2.5 — meaning any machine running Ansible 2.5.0

How to escape double and single quotes in YAML within the same string

房东的猫 提交于 2020-07-17 03:25:26
问题 I need to properly escape single and double quotes in an ansible playbook in order to set the environment variable. None of this works: - name: Set environment variable command: > export EXTRA_CONFIG=“'”{"client": {"subscriptions": ["DIND-Worker"], "cluster": "internal"}}“'” - name: Set environment variable command: > export EXTRA_CONFIG=''{"client": {"subscriptions": ["DIND-Worker"], "cluster": "internal"}}'' - name: Set environment variable command: > export EXTRA_CONFIG=''{\"client\": {\

How to ignore ansible SSH authenticity checking?

拜拜、爱过 提交于 2020-07-16 11:24:08
问题 Is there a way to ignore the SSH authenticity checking made by Ansible? For example when I've just setup a new server I have to answer yes to this question: GATHERING FACTS *************************************************************** The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established. RSA key fingerprint is xx:yy:zz:.... Are you sure you want to continue connecting (yes/no)? I know that this is generally a bad idea but I'm incorporating this in a script that

Using Netbox Ansible Modules

微笑、不失礼 提交于 2020-07-10 10:25:09
问题 I've been wanting to try out Ansible modules available for Netbox [1]. However, I find myself stuck right in the beginning. Here's what I've tried: Add prefix/VLAN to netbox [2]: cat setup-vlans.yml --- - hosts: netbox tasks: - name: Create prefix 192.168.10.0/24 in Netbox netbox_prefix: netbox_token: "{{ netbox_token }}" netbox_url: "{{ netbox_url }}" data: prefix: 192.168.10.0/24 state: present That gives me the following error: ansible-playbook setup-vlans.yml PLAY [netbox] ***************

Does PyNetBox API have an option to verify CA cert for Self Signed Cert?

江枫思渺然 提交于 2020-07-10 03:11:13
问题 I've been trying to play around with NetBox Ansible modules with a NetBox setup having self signed certificate. [1] That however gives me the error: Failed to establish connection to Netbox API I realised that this was due to me using Self signed certificate: >>> import pynetbox >>> nb = pynetbox.api( ... 'https://netbox.url', ... token='XXX' ... ) >>> nb.dcim.devices.all() <snipped> raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='netbox.url', port

Mapping a list of Debian packages in a specific order of 2nd list with Ansible

China☆狼群 提交于 2020-07-09 19:56:30
问题 I'm trying to map a list of files to a list of filenames. The goal is to install Debian files in specific order (base off the list of names). I can retrieve the list of files with a shell command and register them to a list. The goal is to generate a list of filenames in the order of my predefined name list. Then install them in that order. ms2Num.stdout_lines is the list of files from the shell command: # use List -1 to find the file names for the deb files.| grep - name: Find the needed deb