ansible-playbook

Is it possible to run a playbook in “pull mode”?

…衆ロ難τιáo~ 提交于 2019-12-10 17:49:27
问题 I have playbooks which I start on a master host and which run specific actions on remote hosts. This is a "push" mode - the activity is initiated by the master host. Several of my hosts are down at a given time and obviously fail to run the playbook when in such a state. This leads to hosts which are up-to-date, while others are not. To fix this I could run the playbook on the master host in a regular way (via cron for instance) but this is not particularly effective. Is there a built-in way

How do I make an idempontent shell in Ansible

馋奶兔 提交于 2019-12-10 17:06:07
问题 I am using Ansible and I have a little problem trying to make idempotent a shell execution. The first I do is install python-apt package because I need it to use the apt module for install others packages. But every time that I run my playbook the shell task always runs and I want to make it idempotent. Here is my shell task: - name: install pyton-apt shell: apt-get install -y python-apt And here is the output, always running the above task: $ ansible-playbook -i hosts site.yml PLAY [docker]

Ansible - Start Python Flask Script in New Terminal Window

亡梦爱人 提交于 2019-12-10 16:24:41
问题 I have a Flask app that I'd like to deploy and start using Ansible. I've already got my playbook setup to install all the dependencies needed but I'm having trouble getting Ansible to start my application. I've used command and shell both of which do startup the Flask app, but they block Ansible from exiting and Flask doesn't popup in it's own terminal window, which makes it difficult to visually debug and see what Flask is doing. #Current playbook; both command and shell act the same way

How do you Ensure a Line Exists and is Uncommented with Ansible LineinFile?

穿精又带淫゛_ 提交于 2019-12-10 13:34:38
问题 How do you ensure a specific line exists in a file and is uncommented with ansible's `lineinfile' The line I want uncommented (in .htaccess ): #php_flag display_errors on I have used the following: - name: Make sure PHP Errors are turned on lineinfile: dest={{ www_path }}/.htaccess line="php_flag display_errors on" 回答1: Actually your example works as is: Contents of the .htaccess file: #php_flag display_errors on The ansible play: - name: Make sure PHP Errors are turned on lineinfile: dest: "

Authentication or permission failure, did not have permissions on the remote directory

穿精又带淫゛_ 提交于 2019-12-10 12:55:36
问题 I am using ansijet to automate the ansible playbook to be run on a button click. The playbook is to stop the running instances on AWS. If run, manually from command-line, the playbook runs well and do the tasks. But when run through the web interface of ansijet , following error is encountered Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to

Pass Ansible variables from one role (running on one host) to another role running on another host within the same playbook

不想你离开。 提交于 2019-12-10 03:36:19
问题 I have a playbook that runs different roles on different hosts. Is it possible to pass a variable from one role running on one host to another role on another host running within the same playbook run? Or any workaround ? playbook host1 role1 here I get some variables: var1 var2 ...etc host2 role2 here I need to use var1 var2 ... etc from the above host/role The task in role1 that sets teh variable db looks like this: - shell: cd /ACE/conf && grep ^db.url local1.properties | awk -F/ '{print

Is it possible to use Ansible authorized_key exclusive with multiple keys?

江枫思渺然 提交于 2019-12-10 02:11:54
问题 I'm fairly new in using Ansible and have been reading here and google and haven't found an answer yet. My scenario is that I have 1 user on a server but 2-3 different pub keys that need to put in it's authorized_keys file. I can successfully remove all keys, or add all keys with this script: --- - hosts: all tasks: - name: update SSH keys authorized_key: user: <user> key: "{{ lookup('file', item) }}" state: present #exclusive: yes with_fileglob: - ../files/pub_keys/*.pub With the present flag

Ansible - Default/Explicit Tags

£可爱£侵袭症+ 提交于 2019-12-09 15:32:45
问题 I've got a playbook that includes and tags various roles: - name: base hosts: "{{ host | default('localhost') }}" roles: - { role: apt, tags: [ 'base', 'apt', 'ubuntu']} - { role: homebrew, tags: [ 'base', 'homebrew', osx' ]} - { role: base16, tags: [ 'base', 'base16', 'osx' ]} - { role: nodejs, tags: [ 'base', 'nodejs' ]} - { role: tmux, tags: [ 'base', 'tmux' ]} - { role: vim, tags: [ 'base', 'vim' ]} - { role: virtualenv, tags: [ 'base', virtualenv', 'python' ]} - { role: homebrew_cask,

Commenting out a line with Ansible lineinfile module

北战南征 提交于 2019-12-09 14:36:36
问题 I find it hard to believe there isn't anything that covers this use case but my search has proved fruitless. I have a line in /etc/fstab to mount a drive that's no longer available: //archive/Pipeline /pipeline/Archives cifs ro,credentials=/home/username/.config/cifs 0 0 What I want is to change it to #//archive/Pipeline /pipeline/Archives cifs ro,credentials=/home/username/.config/cifs 0 0 I was using this --- - hosts: slurm remote_user: root tasks: - name: Comment out pipeline archive in

running an ansible local task in a remote playbook

南笙酒味 提交于 2019-12-09 14:30:40
问题 I'm trying to get this task to run locally (on the machine that is running the playbook) : - name: get the local repo's branch name local_action: git branch | awk '/^\*/{print $2}' register: branchName I tried plenty of variations with no success all other tasks are meant to run on the target host, which is why running the whole playbook local is not an option TASK: [get the local repo's branch name] ************************************** <127.0.0.1> REMOTE_MODULE git branch | awk '/^\*/