ansible-facts

ansible output printing unwanted things. how to format and display only specific data's

谁说我不能喝 提交于 2019-12-24 01:41:31
问题 I am using ansible 2.4 in centos, trying to run the below script in remote servers and getting the output. Here the problem is yum info output is showing with json format also. But i need to display only the output. How to remove the json format. --- - hosts: GeneralServer tasks: - name: Checking the service status shell: systemctl status {{ item }} with_items: - httpd - crond - postfix - sshd register: service - debug: var=service - name: Checking the package info shell : yum info {{ item }}

How do you change ansible_default_ipv4?

这一生的挚爱 提交于 2019-12-20 18:42:32
问题 I'd like to change ansible_default_ipv4 to point to eth1 instead of eth0. Can I do this in either the playbook or via the --extra-vars option? 回答1: ansible uses command ip -4 route get 8.8.8.8 to get the default ipv4 interface. You can change your ip/routing tables to make eth1 the default route and it'll return it. Or you can use a custom fact. PS: using set_fact to override the ansible_default_ipv4 fact, but it has it's own pitfalls due to caching, scope, ... 回答2: Another option is always

How do you change ansible_default_ipv4?

ε祈祈猫儿з 提交于 2019-12-20 18:42:17
问题 I'd like to change ansible_default_ipv4 to point to eth1 instead of eth0. Can I do this in either the playbook or via the --extra-vars option? 回答1: ansible uses command ip -4 route get 8.8.8.8 to get the default ipv4 interface. You can change your ip/routing tables to make eth1 the default route and it'll return it. Or you can use a custom fact. PS: using set_fact to override the ansible_default_ipv4 fact, but it has it's own pitfalls due to caching, scope, ... 回答2: Another option is always

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

use ansible_facts in module code

↘锁芯ラ 提交于 2019-12-18 09:37:03
问题 I am trying to create my own ansible module (which will update cmdb) and i am looking how to use ansible_facts in module code ? example of my module script is : #!/usr/bin/python from ansible.module_utils.basic import * import json, ast from servicenow import ServiceNow from servicenow import Connection def __get_server_info(table,server_name="", sys_id=""): if sys_id == "": return table.fetch_one({'name': server_name}) if server_name == "": return table.fetch_one({'sys_id': sys_id}) def _

Ansible concat vars to string

被刻印的时光 ゝ 提交于 2019-12-18 09:22:38
问题 I've spent most of the day trying to solve this problem and have thus far failed. I am building some playbooks to automate functions in Splunk, and am attempting to convert a list of hosts from an inventory group E.G. [search_head] 1.2.3.4 5.6.7.8 My expected (desired) result from the debug output of the play should be: https://1.2.3.4:8089, https://5.6.7.8:8089 I am attempting to complete this by running the following playbook against a running host: --- - name: Build search head list to

How to get the first element of a list from the output of setup module in Ansible?

▼魔方 西西 提交于 2019-12-17 07:42:34
问题 I received the following data from the setup module: "ansible_nodename": "3d734bc2a391", "ansible_os_family": "RedHat", "ansible_pkg_mgr": "yum", "ansible_processor": [ "AuthenticAMD", "AMD PRO A10-8700B R6, 10 Compute Cores 4C+6G" ], "ansible_processor_cores": 1, "ansible_processor_count": 1, "ansible_processor_threads_per_core": 1, I want to retrieve the 1st value of ansible_processor and use it in a Jinja2 template. If I use {{ ansible_processor }} , it's giving me both values:

how to set ansible fact from an array with whitespace

大兔子大兔子 提交于 2019-12-13 08:36:12
问题 i am trying to set facts from a json array, since the key contains space i am unable to parse, can someone help me here, i want to set fact as "name": "IN-FG-04" when "vdom": "vdom-shop" Please see my sample playbook entry - name: Iterate JSON set_fact: app_item: "{{ item['scope member'] }}" with_items: "{{ result.results }}" register: app_result please see the json input and this is an output of my previous task { "msg": { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python"

How to use a dictionary of registered ansible variables in vars?

主宰稳场 提交于 2019-12-12 14:21:05
问题 I want to pass multiple variables to a task using vars . Currently, I am doing it like below vars: var1_name: "var1_value" var2_name: "var2_value" As the number of variables can grow in size, I'd rather prefer to pass the dictionary of variables to the task using vars . I have constructed a dictionary of variables like below - name: set fact hosts: localhost tasks: - set_fact: variables: "{{ variables|default({}) | combine( {item.variable: item.value} ) }}" with_items: - variable: var1_name

How to pass second list in to play

被刻印的时光 ゝ 提交于 2019-12-11 19:34:03
问题 I am trying to apply list of items in to when condition and it is not working as expected First list which is applied in the loop { "list2": [ { "apname": "Standard", "dname": "dom-cn-1", "name": "cluster-01", "names": [ "device-cn-c1", "device-cn-c2" ], "type": "CpmiGatewayclusterter" }, { "apname": "PolicyPKG1", "dname": "dom-cn-1", "name": "cluster-cn-02", "names": [ "device-cn-4", "device-cn-c3" ], "type": "CpmiGatewayclusterter" }, { "apname": "Standard", "dname": "dom-cn-2", "name":