ansible-playbook

Need to hide failed log in ansible task

[亡魂溺海] 提交于 2021-02-18 10:43:30
问题 I am new to ansible tasks, am creating a yml which performs a login operation and if login gets failed, some script need to be called. - name: Logging Action shell: "/usr/local/bin/cqlsh -u xyzyx -p 1234abc" register: loginoutput ignore_errors: yes no_log: True - name: Run the cql script to create new user shell: sh create-new-user.cql" when: loginoutput|failed for the above one i created taks that works fine. My question, when performing login operation - it got failed and showing error

how to specify user name in host file of ansible

本小妞迷上赌 提交于 2021-02-18 10:03:45
问题 I am using the host file as below, [qa-workstations] 10.39.19.190 ansible_user=test ansible_ssh_pass=test I am using below command to execute "whoami" command in host root@Svr:~/ansible# ansible all -a "whoami" -i /etc/ansible/host 10.39.19.190 | success | rc=0 >> root ansible by default trying to use user name in which I have logged in, i.e root instead of test user which I have specified in host file It works fine when I try to pass the username in ansible cli command root@Svr:~/ansible#

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:

Why I cannot prompt for a variable that will be shared by multiple plays (ansible 1.6.5)

时光总嘲笑我的痴心妄想 提交于 2021-02-05 18:51:42
问题 I have distilled a playbook that has three plays. The goal is to collect the database password from a prompt in one play and then use the same password in the other two plays. --- - name: database password hosts: - webservers - dbservers vars_prompt: - name: "db_password" prompt: "Enter Database Password for databse user root" default: "root" - hosts: dbservers tasks: - command: echo {{db_password | mandatory }} - hosts: webservers tasks: - command: echo {{db_password | mandatory }} It fails

Why I cannot prompt for a variable that will be shared by multiple plays (ansible 1.6.5)

≡放荡痞女 提交于 2021-02-05 18:51:32
问题 I have distilled a playbook that has three plays. The goal is to collect the database password from a prompt in one play and then use the same password in the other two plays. --- - name: database password hosts: - webservers - dbservers vars_prompt: - name: "db_password" prompt: "Enter Database Password for databse user root" default: "root" - hosts: dbservers tasks: - command: echo {{db_password | mandatory }} - hosts: webservers tasks: - command: echo {{db_password | mandatory }} It fails

Write data with a PUT request with Ansible URI module

坚强是说给别人听的谎言 提交于 2021-01-28 04:53:41
问题 I'm just trying to translate this cURL call to ansible playbook. cURL call: curl -X PUT -d "value={aa}" "http://172.31.64.174:2379/v2/keys/coreos.com/network/config" Ansible playbook: - uri: url: "http://172.31.64.174:2379/v2/keys/coreos.com/network/config" method: PUT body: "value={aa}" I tried this one but server receive the PUT petition but value is not changed. This is the verbose output from the cURL procedure: * Trying 172.31.64.174... * Connected to 172.31.64.174 (172.31.64.174) port

Ansible - when conditional not working for vars_prompt at playbook level

人走茶凉 提交于 2021-01-27 19:33:38
问题 ansible 2.1.2.0 I have a situation here for which I'm trying to check with you all to see if the solution is even possible with Ansible vars_prompt feature and when conditional. Ansible has this feature called: vars_prompt and I want to club this with the when conditional ( when: ... which we generally use in tasks at task or playbook level actions) PS: My question is different than this post : Ansible to Conditionally Prompt for a Variable? i.e. my vars: variables are not dependent upon any

Run only one task and handler from ansible playbook

此生再无相见时 提交于 2021-01-01 07:02:06
问题 How can I run a single task from an Ansible playbook and the handler that gets notified when that task completes successfully, while skipping all other tasks in the relevant playbook? Currently I execute the following: ansible-playbook --start-at-task "task1" --step -K -i hosts playbook.yml and then press Ctrl + c after the task has finished. This will also skip the handler however. I know I can add a tag to the task and use that, as in How to run only one task in ansible playbook?, but I

Ansible Playbooks vs Roles

拥有回忆 提交于 2020-12-27 07:31:15
问题 According to the Ansible docs, a Playbook is: ...the basis for a really simple configuration management and multi-machine deployment system, unlike any that already exist, and one that is very well suited to deploying complex applications. And, again, according to those same docs, a Roles are: ...ways of automatically loading certain vars_files, tasks, and handlers based on a known file structure. Grouping content by roles also allows easy sharing of roles with other users. However the