ansible

Ansible - Windows path variable

我的梦境 提交于 2021-01-29 05:33:17
问题 Is there away to use variables and string together? For example I would like to, define my path's and other options combining variables and string? #Add Directory - name: Add Directory win_file: path: "{{directory_path}}\AppName-{{env}}" state: directory #Add IUSR to directory path - name: ADD IUSR win_acl: path: "{{directory_path}}\AppName-{{env}}" user: IUSR rights: Read type: allow state: present propagation: 'NoPropagateInherit' #Add website - name: "{{env}} Add App Name" win_iis_website:

Ansible access same group vars different children host groups

血红的双手。 提交于 2021-01-29 05:32:41
问题 I am trying to run a role which loops based on a parent group (or parent of parent group) with two or more child groups with certain number of hosts. The two child groups have same group_vars so I tried to define the group_vars separately for each child group but executing the role only inherits group_vars from either of the child group. I understand about the Ansible variable merging but my specific use case (want to run same role at different hierarchies of host groups) needs to load the

How to archive multiple folders under one folder using Ansible

醉酒当歌 提交于 2021-01-29 05:16:08
问题 I'm using the below ansible-playbook code to archive multiple folders under IBM folder. Below is my absolute path Directory structure: /app |-- /IBM |--/test |--/log |--/common |--/api I wish to build an archive (gz) that has only IBM folder containing only common and api folders. Thus, I wrote the below playbook: - name: Creating the archive archive: path: - /was/IBM/common - /was/IBM/api dest: /var/backup/mysetup.tar.gz exclude_path: - /was/IBM/log - /was/IBM/test format: gz This gives me

remote tmp directory not set for ansible script execution

我与影子孤独终老i 提交于 2021-01-29 04:34:49
问题 I need to install binary on remote servers. Following are the list of tasks that i am performing. Copy/scp binary to remote server Run the installer in silent mode Step #1 is copying binaries to /tmp , on remote hosts /tmp has very less space and scp is failing once the /tmp is full. I understood that by default ansible scripts/files will be copied to /tmp directory, once the activity is done it will be removed. Since /tmp is very low i need to use user directory to copy the binaries. Below

Correct way to setup the environment when developing custom ansible modules that use 3rd party python libraries

点点圈 提交于 2021-01-29 02:12:04
问题 I have developed a custom ansible module that has a dependency on a 3rd party library PyYAML. However running the playbook yields ansible_module_my_module.py, line 5, in <module> import yaml ImportError: No module named yaml I see PyYAML in the ansible requirements.txt (https://github.com/ansible/ansible/blob/stable-2.8/requirements.txt) so I know its installed/used on the host machine. I'm wondering if there is a recommended way to install it on the remote machine? I can add a step in the

Rundeck variable from script steps to Inline Ansible Playbook

大憨熊 提交于 2021-01-29 00:01:44
问题 I need to download a file from web URL and inflate into remote server, which does not have internet access. Rundeck downloads the file into local path wget, then push the file to destination server using SSH Rundeck to execute script on remote node to inflate the file copied using above step and perform other housekeeping activity, (its a bash shell script) I am with very little knowledge on using Rundeck. Step one , I have got it done. File is downloaded to rundeck from URL and pushed to

Rundeck variable from script steps to Inline Ansible Playbook

五迷三道 提交于 2021-01-29 00:00:34
问题 I need to download a file from web URL and inflate into remote server, which does not have internet access. Rundeck downloads the file into local path wget, then push the file to destination server using SSH Rundeck to execute script on remote node to inflate the file copied using above step and perform other housekeeping activity, (its a bash shell script) I am with very little knowledge on using Rundeck. Step one , I have got it done. File is downloaded to rundeck from URL and pushed to

using 'sudo bash' to elevate user permission with ansible

会有一股神秘感。 提交于 2021-01-28 23:30:38
问题 I am currently working on a system that the only way to become root is via the command "sudo bash". My intentions are to use Ansible to install dependencies and configure files, and the currently documented methods of privilege escalation do not work with my current system setup. 回答1: If only sudo bash is available for you, then ansible with a controler <-> remote host connection is not a good candidate as this is a known limitation of the privilege escalation feature. To explain a bit

Delete all old files, but keep newest 4 files using ansible-playbook

倾然丶 夕夏残阳落幕 提交于 2021-01-28 22:14:16
问题 I would like to delete all old files, and keep newest 4 files. The output isn't what i expected. Even i use absent on file modules, but it doesn't delete the files. My files are here # ls -l /home/tomcat/backup total 0 -rw-r--r-- 1 root root 0 Mar 3 14:21 1 -rw-r--r-- 1 root root 0 Mar 3 14:21 2 -rw-r--r-- 1 root root 0 Mar 3 14:21 3 -rw-r--r-- 1 root root 0 Mar 3 14:21 4 -rw-r--r-- 1 root root 0 Mar 3 14:21 5 -rw-r--r-- 1 root root 0 Mar 3 14:21 6 -rw-r--r-- 1 root root 0 Mar 3 14:21 as -rw

Is there a way in Ansible to replace a dictionary value based on k:v lookup to another dictionary?

南楼画角 提交于 2021-01-28 21:02:38
问题 I have k:v dictionary of hostname: IP that I want to use in a lookup from another dictionary to replace entries matching key from 1st dictionary and replacing it with the corresponding value in 2nd dictionary; 1st: "nb_console_ip": { "office-con01": "10.20.30.100", 2nd: "nb_console_port": [ { "console": "office-con01", "hostname": "office-core01", "port": "con1" }, { "console": "office-con01", "hostname": "office-core02", "port": "con2" }, { "console": "office-con01", "hostname": "office-fw01