-
-
Save vmoravec/935b66d2f11b5ca094384318690859b3 to your computer and use it in GitHub Desktop.
ansible - example of command and with_items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: foo | |
vars: | |
gems: | |
libxml-ruby: { version: 2.6.0, state: present, include_dependencies: yes, user_install: no } | |
shenzhen: { version: 0.13.1, state: present, include_dependencies: yes, user_install: no } | |
gem_executable: /usr/local/rvm/ruby/blah/blah/1.2/gem | |
tasks: | |
- name: install a bunch of gems - warning, use the right executable and run as the right user! | |
gem: | |
name: "{{ item.key }}" | |
version: "{{ item.version | default(omit) }}" | |
state: "{{ item.state | default(omit) }}" | |
include_dependencies: "{{ item.include_dependencies | default(omit) }}" | |
user_install: "{{ item.user_install | default(omit) }}" | |
executable: "{{ gem_executable }}" | |
with_dict: gems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Install stupid ruby gems with shell commands | |
sudo_user: automationman | |
command: bash -lc "gem install {{ item }}" | |
with_items: | |
- libxml-ruby-2.6.0 | |
- shenzhen-0.13.1 | |
- activesupport -v 4.1.8" | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment