ansible-playbook

Save temporary ansible shell scripts instead of deleting

送分小仙女□ 提交于 2020-01-12 04:02:14
问题 I noticed Ansible removes the temporary script using a semi-colon to separate the bash commands. Here is an example command: EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/devuser/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 build /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/ec2

How to use wildcard with variable [duplicate]

社会主义新天地 提交于 2020-01-07 03:46:11
问题 This question already has answers here : Ansible Command module says that '|' is illegal character (2 answers) Closed last year . I want to list the files as per the host name.But problem is i not able to use the wildcard with variable properly.Can someone suggest me on this. --- - hosts: local become_user: yes vars: filename: /root/stuff tasks: - name: list files action: command ls -lrt {{ filename }}/'*{{ansible_hostname}}' register: listfiles - debug: var=listfiles 回答1: If your question is

Ansible and hardware checks

我是研究僧i 提交于 2020-01-07 00:35:30
问题 I have to check different hardware and configurations elements on Linux machines using ansible, and I am not sure at all about how to do it (RAM, disk space, DNS, CPU...), I've understood that I can find nearly all I want in the ansible facts, but I do not understand how I can use it. For example, I have to check if the RAM amount is at least of 4GB and have an alarm if not, so I tried many things, and... nothing works. Here is an example of what I tried. - hosts: client remote_user: user

Error in Mount Module in Ansible

别来无恙 提交于 2020-01-06 04:45:10
问题 I am trying to mount a remote directory. Following is the code: - name: mount the folder. mount: name=/mnt/point src="//sdfs601/master.src/scm/pkgs" fstype=auto opts="domain=td,username=uname,password=pass,file_mode=0777,dir_mode=0777" state=mounted But it is giving the following error: fatal: [153.64.221.181]: FAILED! => {"changed": false, "failed": true, "msg": "Error mounting /mnt/15.00: mount: special device //sdfs601/master.src/scm/pkgs does not exist\n"} But when i try mounting using

Why does my custom Ansible module fail?

南楼画角 提交于 2020-01-05 11:01:30
问题 I am learning ansible so I wrote the most simple playbook and module I could think of, and it failed. My playbook --- - hosts: demo tasks: - name: install demo action: install My module echo "changed=True msg=OK" The following seems fine : bash script mode is 755 playbook is linked to module correctly This is the output: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "changed=True msg=OK\r\n", "msg": "MODULE FAILURE", "parsed": false} What am I doing wrong

Ansible group_vars

若如初见. 提交于 2020-01-05 09:14:58
问题 I'm trying to automate the deployment of sensu checks to each role that a host plays. I currently have a structure like group_vars/ nginx all In each group_vars file, I have defined the following: sensu_checks: - check_name - check_other_name So for example, in group_vars/all I'd have: sensu_checks: - check_raid - check_load - check_disk In group_vars/nginx I'd have: sensu_checks: - check_pid - check_http What I would like to know if it's possible would be to get all the checks that a

How to copy files from remote to host ansible?

旧时模样 提交于 2020-01-04 02:00:26
问题 I am trying to copy files from a remote host to my local server where I am running Ansible playbook. Though the task always executes successfully but the file is never copied to local server. Here is the code: - file: path: vm_info.config mode: 0777 - fetch: src: vm_info.config dest: . #flat: yes fail_on_missing: yes I tried copy module as well but none of them is getting me the result. 回答1: From fetch - Fetches a file from remote nodes dest - A directory to save the file into. For example,

Permission denied when trying to install inside a virtualenv using ansible

自作多情 提交于 2020-01-03 11:44:59
问题 I have this play in my ansible playbook - name: Setup virtualenv pip: requirements="/vagrant/webapp/requirements/{{ requirements_filename }}" virtualenv="$HOME/.envs/{{ project_name }}" However, I am receiving a Permission denied error. It seems like ansible is trying to install the package into the system path and not into the virtualenv. Here's the full traceback: TASK: [deploy | Setup virtualenv] ********************************************* failed: [default] => {"cmd": "/usr/bin/pip

Permission denied when trying to install inside a virtualenv using ansible

心不动则不痛 提交于 2020-01-03 11:44:49
问题 I have this play in my ansible playbook - name: Setup virtualenv pip: requirements="/vagrant/webapp/requirements/{{ requirements_filename }}" virtualenv="$HOME/.envs/{{ project_name }}" However, I am receiving a Permission denied error. It seems like ansible is trying to install the package into the system path and not into the virtualenv. Here's the full traceback: TASK: [deploy | Setup virtualenv] ********************************************* failed: [default] => {"cmd": "/usr/bin/pip

How to tell what directory was created by ansible's unarchive module?

耗尽温柔 提交于 2020-01-03 07:09:08
问题 I'm writing an ansible playbook to automate the installation of a piece of software. When I download the tarball from the website I have: software-package-release.tar.gz When untarred I'm left with the directory software-package-v2.15/ Does ansible have any way of registering the directory created as part of the unarchive module? I've tried with the following plays (I put the nrpe-lkdsflkdjf file there which contains a dir nrpe-2.15 ) - name: Extract unarchive src:/tmp/nrpe-lkdsflkdjf dest: