ansible

Ansible Message Output based on task result

荒凉一梦 提交于 2021-02-08 10:21:05
问题 Is it possible in Ansible to display different messages based on a result of the task? For example - name: check_prometheus_status_kafka shell: /usr/sbin/ss -lnt|awk '{ print $4}'|grep 9071 |sed 's/\*//'| sed 's/\://' register: prom_status tags: - check_prometheus_status_kafka - name: post_message_prom_kafka debug: msg="Prometheus for Kafka listening in {{ prom_status.stdout }}" when: prom_status.stdout == "9071" tags: - post_message_prom_kafka What I want is an additional message which would

Ansible Message Output based on task result

江枫思渺然 提交于 2021-02-08 10:19:13
问题 Is it possible in Ansible to display different messages based on a result of the task? For example - name: check_prometheus_status_kafka shell: /usr/sbin/ss -lnt|awk '{ print $4}'|grep 9071 |sed 's/\*//'| sed 's/\://' register: prom_status tags: - check_prometheus_status_kafka - name: post_message_prom_kafka debug: msg="Prometheus for Kafka listening in {{ prom_status.stdout }}" when: prom_status.stdout == "9071" tags: - post_message_prom_kafka What I want is an additional message which would

key value pair mapping in ansible to pass run the role with the appropriate value

我的梦境 提交于 2021-02-08 08:09:04
问题 I am new to ansible. I have a small scenario. So I pass the name of the branch using ansible when I run it. In my play book I have: # Deploy docker container - include_role: name: devops/deployment.docker vars: docker_name: "docker name is based on the branch id develop dev if UAT test if master then it should be prod" when: build_type in "develop master UAT" and in devops/deployment.docker I have a role which deploy a docker image. - name: push docker container docker_image: name: "{{ docker

key value pair mapping in ansible to pass run the role with the appropriate value

三世轮回 提交于 2021-02-08 08:01:32
问题 I am new to ansible. I have a small scenario. So I pass the name of the branch using ansible when I run it. In my play book I have: # Deploy docker container - include_role: name: devops/deployment.docker vars: docker_name: "docker name is based on the branch id develop dev if UAT test if master then it should be prod" when: build_type in "develop master UAT" and in devops/deployment.docker I have a role which deploy a docker image. - name: push docker container docker_image: name: "{{ docker

ansibl inventory : create temporary inventory with multiple groups with add_host or group_by

Deadly 提交于 2021-02-08 07:55:55
问题 I have an assignment to provision {{ create new hosts }} according to a given invonteroy file, example [SET1] 1.1.1.1 new_ip=1.1.1.1 [SET2] 1.1.1.2 new_ip=1.1.1.2 [SET3] 1.1.1.3 new_ip=1.1.1.3 Here is the problem. The inventory file contains set of ip addresses that do not exists yet. What I want to do - connect to vsphere host(5.5) - create new machines based on amount of hosts in the inventory - change the machines ip address to match the one in the given inventory modules like vmware_shell

ansibl inventory : create temporary inventory with multiple groups with add_host or group_by

北战南征 提交于 2021-02-08 07:55:44
问题 I have an assignment to provision {{ create new hosts }} according to a given invonteroy file, example [SET1] 1.1.1.1 new_ip=1.1.1.1 [SET2] 1.1.1.2 new_ip=1.1.1.2 [SET3] 1.1.1.3 new_ip=1.1.1.3 Here is the problem. The inventory file contains set of ip addresses that do not exists yet. What I want to do - connect to vsphere host(5.5) - create new machines based on amount of hosts in the inventory - change the machines ip address to match the one in the given inventory modules like vmware_shell

ansibl inventory : create temporary inventory with multiple groups with add_host or group_by

自作多情 提交于 2021-02-08 07:55:38
问题 I have an assignment to provision {{ create new hosts }} according to a given invonteroy file, example [SET1] 1.1.1.1 new_ip=1.1.1.1 [SET2] 1.1.1.2 new_ip=1.1.1.2 [SET3] 1.1.1.3 new_ip=1.1.1.3 Here is the problem. The inventory file contains set of ip addresses that do not exists yet. What I want to do - connect to vsphere host(5.5) - create new machines based on amount of hosts in the inventory - change the machines ip address to match the one in the given inventory modules like vmware_shell

Ansible conditional statements not evaluating correctly

非 Y 不嫁゛ 提交于 2021-02-08 07:40:27
问题 I have an ansible playbook with a couple of tasks that check a directory for files created on todays date and saves them in files . I'm doing my comparison off of files|length and print out two different messages depending if the length is 0 or not. Here is the code: - name: Grabbing all of the files that were created today shell: find /home/user/empty_directory -maxdepth 1 -daystart -ctime 0 -print register: files - debug: var=files.stdout - debug: msg="The directory isn't empty" when: files

can't read custom facts with list (array) of items

折月煮酒 提交于 2021-02-08 01:21:21
问题 i have created custom fact ---> /etc/ansible/facts.d/hdfs.fact when i'm running the playbook with the following command - debug: var=ansible_local.hdfs run_once: true i'm getting as expected the following answer: PLAY [all] ********************************************************************* TASK [setup] ******************************************************************* ok: [cdh-2] ok: [cdh-3] ok: [cdh-1] TASK [preparation : debug] ***************************************************** ok:

API call using Ansible uri module

风流意气都作罢 提交于 2021-02-07 14:55:23
问题 I am trying to use the Ansible uri module to communicate with DeployHQ's API. Here is the example DeployHQ's documentation that I am trying to use from Ansible: curl -H "Content-type: application/json" \ -H "Accept: application/json" \ --user adam@atechmedia.com:my-api-key \ -d '{"deployment":{ "parent_identifier":"7563d091-ca73-588e-cfe2- e4936f190145", \ "start_revision" : "e84b5937f1132932dd56026db26a76f406555c19", \ "end_revision" : "e84b5937f1132932dd56026db26a76f406555c19", \ "mode" :