ansible

How to parse a XML response in ansible?

瘦欲@ 提交于 2020-06-17 07:17:15
问题 I'm running the panos_op ansible module and struggling to parse the output. ok: [localhost] => { "result": { "changed": true, "failed": false, "msg": "Done", "stdout": "{\"response\": {\"@status\": \"success\", \"result\": \"no\"}}", "stdout_lines": [ "{\"response\": {\"@status\": \"success\", \"result\": \"no\"}}" ], "stdout_xml": "<response status=\"success\"><result>no</result></response>" } } This is as close as I can get to assigning the value for "result". ok: [localhost] => { "result

Ansible + Ubuntu 18.04 + MySQL = “The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.”

佐手、 提交于 2020-06-14 00:26:44
问题 I’m seeing the above message on multiple playbooks using Ansible 2.8 on Ubuntu 18.04. In the interests of simplicity I’ve reproduced it using this basic playbook for a single node Drupal server. https://github.com/geerlingguy/ansible-for-devops/tree/master/drupal; this playbook works fine on earlier versions of ubuntu, but not on 18.04 which I understand includes python3 by default. I’ve used vagrant to create the base machine, which shows the following: $ which python /usr/bin/python $ which

Ansible and Git Permission denied (publickey) at Git Clone

最后都变了- 提交于 2020-06-10 10:24:38
问题 I have a playbook where I am trying to clone from a private repo (GIT) to a server. I have setup ssh forwarding and when I ssh into the server and try to manually clone from the same repo, it successfully works. However, when I use ansible for the to clone the repo to the server, it fails with "Permission Denied Public Key". This is my playbook deploy.yml : --- - hosts: webservers remote_user: root tasks: - name: Setup Git repo git: repo={{ git_repo }} dest={{ app_dir }} accept_hostkey=yes

Ansible - How to keep appending new keys to a dictionary when using set_fact module with with_items?

 ̄綄美尐妖づ 提交于 2020-06-09 10:11:50
问题 I want to add keys to a dictionary when using set_fact with with_items. This is a small POC which will help me complete some other work. I have tried to generalize the POC so as to remove all the irrelevant details from it. When I execute following code it is shows a dictionary with only one key that corresponds to the last item of the with_items. It seems that it is re-creating a new dictionary or may be overriding an existing dictionary for every item in the with_items. I want a single

How to kill a running process using ansible?

百般思念 提交于 2020-06-09 09:43:33
问题 I have an ansible playbook to kill running processes and works great most of the time!, however, from time to time we find processes that just can't be killed so, "wait_for" gets to the timeout, throws an error and it stops the process. The current workaround is to manually go into the box, use "kill -9" and run the ansible playbook again so I was wondering if there is any way to handle this scenario from ansible itself?, I mean, I don't want to use kill -9 from the beginning but I maybe a

How to kill a running process using ansible?

為{幸葍}努か 提交于 2020-06-09 09:43:19
问题 I have an ansible playbook to kill running processes and works great most of the time!, however, from time to time we find processes that just can't be killed so, "wait_for" gets to the timeout, throws an error and it stops the process. The current workaround is to manually go into the box, use "kill -9" and run the ansible playbook again so I was wondering if there is any way to handle this scenario from ansible itself?, I mean, I don't want to use kill -9 from the beginning but I maybe a

How to pass terraform outputs variables into ansible as vars_files?

那年仲夏 提交于 2020-06-08 04:16:46
问题 I am provisioning AWS infrastructure using terraform and want to pass variables such as aws_subnet_id and aws_security_id into ansible playbook using vars_file (don't know if there is any other way though). How can I do that? 回答1: terraform outputs are an option, or you can just use something like: provisioner "local-exec" { command = "ANSIBLE_HOST_KEY_CHECKING=\"False\" ansible-playbook -u ${var.ssh_user} --private-key=\"~/.ssh/id_rsa\" --extra-vars='{"aws_subnet_id": ${aws_terraform

How to pass terraform outputs variables into ansible as vars_files?

走远了吗. 提交于 2020-06-08 04:15:32
问题 I am provisioning AWS infrastructure using terraform and want to pass variables such as aws_subnet_id and aws_security_id into ansible playbook using vars_file (don't know if there is any other way though). How can I do that? 回答1: terraform outputs are an option, or you can just use something like: provisioner "local-exec" { command = "ANSIBLE_HOST_KEY_CHECKING=\"False\" ansible-playbook -u ${var.ssh_user} --private-key=\"~/.ssh/id_rsa\" --extra-vars='{"aws_subnet_id": ${aws_terraform

How to pass terraform outputs variables into ansible as vars_files?

断了今生、忘了曾经 提交于 2020-06-08 04:14:18
问题 I am provisioning AWS infrastructure using terraform and want to pass variables such as aws_subnet_id and aws_security_id into ansible playbook using vars_file (don't know if there is any other way though). How can I do that? 回答1: terraform outputs are an option, or you can just use something like: provisioner "local-exec" { command = "ANSIBLE_HOST_KEY_CHECKING=\"False\" ansible-playbook -u ${var.ssh_user} --private-key=\"~/.ssh/id_rsa\" --extra-vars='{"aws_subnet_id": ${aws_terraform

ansible - How to add a password prompt in tasks file

夙愿已清 提交于 2020-06-01 07:41:07
问题 In short... how can I make something like this work (without vars_prompt ?!): - name: Manual User - Input Password delegate_to: localhost pause: prompt: "Enter password" private: yes encrypt: "sha512_crypt" confirm: yes salt_size: 7 register: password_manual_user As "prompt" in pause is not the same as the prompt module, this does not work. But it shows what I would like to achieve. More details... I am setting up a new cloud server in an ansible playbook, this works fine. I then want to add