ansible

How to call ansible playbook in terraform code?

强颜欢笑 提交于 2021-01-27 17:35:34
问题 I have an ansible playbook which works well , now I have to call that playbook using terrform scripts. Currently I m using code which is shown below but it results in error during terraform init as: Error: Unknown root level key: provisioner I am using Terraform v0.11.7 and the error occurs only when I run this specific code. Also my main.tf consists of only this code. The directory structure I have used is such as : . ├── create-user.yml ├── library │ └── mkpassword.py ├── main.tf ├──

Ansible truncate concatentated string

心已入冬 提交于 2021-01-27 13:09:23
问题 I am generating an yaml template in Ansible and I am trying to truncate two concatenated strings: Here the following code doesn't work because of the concatenation does not pipe into the regex_replace correctly. I am only wanting the first n characters (first 10 characters in this example) Normally I could just combine these two into one variable and then do {{variabel [:10] }} But I am no able to do that in this case because the file I am working in is getting combined with variables and

Ansible win_package stuck forever

纵饮孤独 提交于 2021-01-27 12:29:53
问题 I am using win_package module for installing "Nessus" in Windows 2016 server. But whenever I execute it, it hangs forever without response. Even after waiting for an hour, there is no response. I have already kept Nessus installer in Windows server directory as mentioned in the code. Please help. Playbook main file: --- - name: Windows Install Nessus gather_facts: yes hosts: windows vars_files: - /etc/ansible/vars/Win_Vars.yml tasks: - import_tasks: Install_Nessus.yml Playbook Task file

Ansible: shell script output always empty

ⅰ亾dé卋堺 提交于 2021-01-27 07:08:46
问题 I'm trying to insert an output of Linux shell to a variable, but for some reason, the variable always empty. Here is the Ansible code: - name: Check PHP version shell: php -v 2> /dev/null | awk '{print $2; exit}' register: php_version - debug: var=php_version And here is the output: ok: [10.0.0.5] => { "php_version": { "changed": true, "cmd": "php -v 2> /dev/null | awk '{print $2; exit}'", "delta": "0:00:00.015180", "end": "2017-01-08 18:41:00.323773", "rc": 0, "start": "2017-01-08 18:41:00

Use Ansible facts in an Ansible ad-hoc command

女生的网名这么多〃 提交于 2021-01-27 06:06:08
问题 Is it possible to use what would normally be included in ansible_facts in an Ansible adhoc command? For example, I have a file at /tmp/myFile on all of my servers and I'd like to do: ansible all -i [inventory file] -m fetch -a "src=/tmp/myFile dest=myFile-[insert ansible_hostname here]" Without having to make a whole playbook for it. 回答1: No you cannot refer to ansible facts in ansible cli. This is because when you run ansible ... -m fetch you are not getting the facts of the host(s) you are

Use Ansible facts in an Ansible ad-hoc command

偶尔善良 提交于 2021-01-27 06:05:00
问题 Is it possible to use what would normally be included in ansible_facts in an Ansible adhoc command? For example, I have a file at /tmp/myFile on all of my servers and I'd like to do: ansible all -i [inventory file] -m fetch -a "src=/tmp/myFile dest=myFile-[insert ansible_hostname here]" Without having to make a whole playbook for it. 回答1: No you cannot refer to ansible facts in ansible cli. This is because when you run ansible ... -m fetch you are not getting the facts of the host(s) you are

Ansible with_dict expects a dict

∥☆過路亽.° 提交于 2021-01-27 05:06:20
问题 I know this question has been asked many times before but I must be missing something here! This is a minimal playbook to reproduce the issue. Here is the playbook: --- - hosts: - localhost gather_facts: false vars: zones_hash: location1: id: 1 control_prefix: '10.1.254' data_prefix: '10.1.100' location2: id: 2 control_prefix: '10.2.254' data_prefix: '10.2.100' tasks: - name: "test1" debug: var="zones_hash" - name: "test2" debug: var="item" with_dict: - "{{ zones_hash }}" Here is the output:

Ansible with_dict expects a dict

狂风中的少年 提交于 2021-01-27 05:05:56
问题 I know this question has been asked many times before but I must be missing something here! This is a minimal playbook to reproduce the issue. Here is the playbook: --- - hosts: - localhost gather_facts: false vars: zones_hash: location1: id: 1 control_prefix: '10.1.254' data_prefix: '10.1.100' location2: id: 2 control_prefix: '10.2.254' data_prefix: '10.2.100' tasks: - name: "test1" debug: var="zones_hash" - name: "test2" debug: var="item" with_dict: - "{{ zones_hash }}" Here is the output:

Ansible with_dict expects a dict

最后都变了- 提交于 2021-01-27 05:05:34
问题 I know this question has been asked many times before but I must be missing something here! This is a minimal playbook to reproduce the issue. Here is the playbook: --- - hosts: - localhost gather_facts: false vars: zones_hash: location1: id: 1 control_prefix: '10.1.254' data_prefix: '10.1.100' location2: id: 2 control_prefix: '10.2.254' data_prefix: '10.2.100' tasks: - name: "test1" debug: var="zones_hash" - name: "test2" debug: var="item" with_dict: - "{{ zones_hash }}" Here is the output:

每日学习-ansible任务委派与本地操作

北战南征 提交于 2021-01-24 09:02:32
ansible通过使用delegate_to关键字委派任务到指定的机器上运行 使用示例: 1、hosts配置 - name: add host record to DC server shell: 'echo "192.168.10.12 node2" >> /etc/hosts' - name: add host record to all server shell: 'echo "192.168.10.12 node2 " >> /etc/hosts' delegate_to: 192.168.10.100 2、ntp-server配置 ntp-server执行server配置,nep-client执行定时任务同步server。 - name: install ntp shell: yum -y install ntp - name: stop all ntp_install server shell: systemctl stop ntpd && systemctl disable ntpd - name: config ntp server template: src=templates/ntp.conf dest=/etc/ntp.conf run_once: true delegate_to: "{{ntp.ntp_server}}" - name: start ntp