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
--- | |
############################################################ | |
# The lookup on line 9 is currenlty failing. | |
# Can anyone recommend how I can achieve the following? | |
# Is there a better way to go about doing what I've set out to do here? | |
############################################################ | |
- name: Add user {{ user }} | |
user: name={{user}} |
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
--- | |
# (Ansible version 1.4) | |
# | |
# ERROR: Syntax Error while loading YAML script, /Users/danrough/Documents/Development/OpsScripts/ansible/base-build/roles/common/tasks/main.yml | |
# Note: The error may actually appear before this position: line 14, column 3 | |
# | |
# - { include: user.yml, user: {{ users.username }}, sudo: {{ users.isSudo }} } | |
# with_items: users | |
# ^ |
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: Spin up the services | |
template: src=service_init.j2 dest=/etc/init.d/{{ item.service_name }} owner=root group=root mode=777 | |
with_items: | |
- { service_name: paymentHandler, service_user: blackjack_attack, service_exec: "{{ application_directory }}/apps/paymentHandler.js" } |
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: Create the service init scripts yo | |
template: src=service_init_script.j2 dest=/etc/init.d/{{ item.service_name }} owner=root group=root mode=755 | |
with_items: | |
- { service_name: paymentHandler, service_description: 'Handles payments', service_user: blackjack_attack, service_exec: "{{ application_directory }}/apps/paymentHandler.js" } | |
- { service_name: tablePool, service_description: 'The pool of tables available', service_user: blackjack_attack, service_exec: "{{ application_directory }}/apps/tablePool.js" } | |
- { service_name: userManager, service_description: 'Manages users, apparently', service_user: blackjack_attack, service_exec: "{{ application_directory }}/apps/userManager.js" } | |
sudo: yes |
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
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: {{ item.service_name }} | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: {{ item.service_description }} | |
### END INIT INFO |
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
define hostgroup { | |
hostgroup_name web_servers | |
alias Web servers | |
members {% for host in groups['web'] %}{{ hostvars[host]['ansible_ssh_host'] }}{% if not loop.last %}, {% endif %}{% endfor %} | |
} |
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: Gather information from the inventory file about all hosts for later use | |
hosts: all | |
gather_facts: no | |
- name: Build test infrastructure | |
hosts: localhost | |
gather_facts: no | |
connection: local |
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: App servers | |
local_action: | |
module: rax | |
credentials: ~/.rackspace_cloud_credentials | |
region: "{{ region }}" | |
name: "{{ target_environment }}-{{ region }}-app-%02d" | |
count: "{{ app_server_count }}" | |
exact_count: yes | |
group: "{{ target_environment }}_app_servers" |
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: App servers | |
local_action: | |
module: rax | |
credentials: ~/.rackspace_cloud_credentials | |
region: "{{ region }}" | |
name: "{{ target_environment }}-{{ region }}-app-%02d" | |
count: "{{ app_server_count }}" | |
exact_count: yes | |
group: "{{ target_environment }}_app_servers" |
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: localhost | |
gather_facts: no | |
vars: | |
database_clusters: | |
- { cluster_name: "test_lon", port: 5433 } | |
- { cluster_name: "prod_lon", port: 5434 } | |
tasks: | |
- name: Port for {{ environment }}_{{ region | lower }} | |
debug: var="{{ database_clusters | selectattr('cluster_name', 'equalto', '{{ environment }}_{{ region | lower }}') | map(attribute='port') | join(',') }}" |