Commit 031f7ab9 by Arbab Nazar Committed by GitHub

Merge pull request #3134 from edx/arbab/aws-rewrite

use fully expanded YAML dictionaries for ansible tasks
parents 658f6566 0b2af04c
...@@ -24,71 +24,80 @@ ...@@ -24,71 +24,80 @@
# #
# Start dealing with Jumbo frames issue in mixed MTU deployements in AWS # Start dealing with Jumbo frames issue in mixed MTU deployements in AWS
# #
- name: gather ec2 facts for use in other roles - name: Gather ec2 facts for use in other roles
action: ec2_facts action: ec2_facts
tags: tags:
- deploy - deploy
- shell: > - name: Set the MTU to 1500 temporarily
/sbin/ifconfig eth0 mtu 1500 up shell: /sbin/ifconfig eth0 mtu 1500 up
when: ansible_distribution in common_debian_variants when: ansible_distribution in common_debian_variants
- name: check for eth0.cfg - name: Check for eth0.cfg
stat: path=/etc/network/interfaces.d/eth0.cfg stat:
path: /etc/network/interfaces.d/eth0.cfg
register: eth0_cfg register: eth0_cfg
when: ansible_distribution in common_debian_variants when: ansible_distribution in common_debian_variants
- lineinfile: > - name: Set the MTU to 1500 inside eth0.cfg file
dest=/etc/network/interfaces.d/eth0.cfg lineinfile:
regexp="^post-up /sbin/ifconfig eth0 mtu 1500" dest: /etc/network/interfaces.d/eth0.cfg
line="post-up /sbin/ifconfig eth0 mtu 1500" regexp: "^post-up /sbin/ifconfig eth0 mtu 1500"
insertafter="^iface" line: "post-up /sbin/ifconfig eth0 mtu 1500"
insertafter: "^iface"
when: ansible_distribution in common_debian_variants and eth0_cfg.stat.exists when: ansible_distribution in common_debian_variants and eth0_cfg.stat.exists
# #
# End dealing with Jumbo frames issue in mixed MTU deployements in AWS # End dealing with Jumbo frames issue in mixed MTU deployements in AWS
# #
- name: create all service directories - name: Create all service directories
file: > file:
path="{{ item.value.path }}" path: "{{ item.value.path }}"
state="directory" state: directory
owner="{{ item.value.owner }}" owner: "{{ item.value.owner }}"
group="{{ item.value.group }}" group: "{{ item.value.group }}"
mode="{{ item.value.mode }}" mode: "{{ item.value.mode }}"
with_dict: aws_dirs with_dict: "{{ aws_dirs }}"
- name: install system packages - name: Install system packages
apt: > apt:
pkg={{','.join(aws_debian_pkgs)}} name: "{{ item }}"
state=present state: present
update_cache=yes update_cache: yes
with_items: "{{ aws_debian_pkgs }}"
when: ansible_distribution in common_debian_variants when: ansible_distribution in common_debian_variants
- name: install aws python packages - name: Install aws python packages
pip: > pip:
name="{{ item }}" state=present name: "{{ item }}"
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}" state: present
with_items: aws_pip_pkgs extra_args: "-i {{ COMMON_PYPI_MIRROR_URL }}"
with_items: "{{ aws_pip_pkgs }}"
- name: create s3 log sync script - name: Create s3 log sync script
template: > template:
dest={{ aws_s3_sync_script }} dest: "{{ aws_s3_sync_script }}"
src=send-logs-to-s3.j2 mode=0755 owner=root group=root src: send-logs-to-s3.j2
mode: 0755
owner: root
group: root
when: AWS_S3_LOGS when: AWS_S3_LOGS
- name: create symlink for s3 log sync script - name: Create symlink for s3 log sync script
file: > file:
state=link state: link
src={{ aws_s3_sync_script }} src: "{{ aws_s3_sync_script }}"
dest={{ COMMON_BIN_DIR }}/{{ aws_s3_sync_script|basename }} dest: "{{ COMMON_BIN_DIR }}/{{ aws_s3_sync_script|basename }}"
when: AWS_S3_LOGS when: AWS_S3_LOGS
- name: force logrotate on supervisor stop - name: Force logrotate on supervisor stop
template: > template:
src=etc/init/sync-on-stop.conf.j2 src: etc/init/sync-on-stop.conf.j2
dest=/etc/init/sync-on-stop.conf dest: /etc/init/sync-on-stop.conf
owner=root group=root mode=0644 owner: root
group: root
mode: 0644
when: AWS_S3_LOGS when: AWS_S3_LOGS
# update the ssh motd on Ubuntu # update the ssh motd on Ubuntu
...@@ -96,25 +105,24 @@ ...@@ -96,25 +105,24 @@
# and add a custom motd. These do not require an # and add a custom motd. These do not require an
# ssh restart # ssh restart
# Only needed for EC2 instances. # Only needed for EC2 instances.
- name: update the ssh motd on Ubuntu - name: Update the ssh motd on Ubuntu
file: > file:
mode=0644 path: "{{ item }}"
path={{ item }} mode: 0644
when: vagrant_home_dir.stat.exists == false when: (vagrant_home_dir.stat.exists == false) and (ansible_distribution in common_debian_variants)
with_items: with_items:
- "/etc/update-motd.d/10-help-text" - "/etc/update-motd.d/10-help-text"
- "/usr/share/landscape/landscape-sysinfo.wrapper" - "/usr/share/landscape/landscape-sysinfo.wrapper"
- "/etc/update-motd.d/51-cloudguest" - "/etc/update-motd.d/51-cloudguest"
- "/etc/update-motd.d/91-release-upgrade" - "/etc/update-motd.d/91-release-upgrade"
when: ansible_distribution in common_debian_variants
- name: update /etc/dhcp/dhclient.conf - name: Update /etc/dhcp/dhclient.conf
template: template:
src: etc/dhcp/dhclient.conf.j2 src: etc/dhcp/dhclient.conf.j2
dest: /etc/dhcp/dhclient.conf dest: /etc/dhcp/dhclient.conf
when: COMMON_CUSTOM_DHCLIENT_CONFIG when: COMMON_CUSTOM_DHCLIENT_CONFIG
- name: copy the MOTD template in place - name: Copy the MOTD template in place
template: template:
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
src: "{{ item.src }}" src: "{{ item.src }}"
...@@ -140,14 +148,18 @@ ...@@ -140,14 +148,18 @@
line: "PasswordAuthentication {{ COMMON_SSH_PASSWORD_AUTH }}" line: "PasswordAuthentication {{ COMMON_SSH_PASSWORD_AUTH }}"
register: sshd_config register: sshd_config
- name: restart ssh - name: Restart ssh
service: name=ssh state=restarted service:
name: ssh
state: restarted
become: True become: True
when: sshd_config.changed when: sshd_config.changed
when: ansible_distribution in common_debian_variants when: ansible_distribution in common_debian_variants
- name: restart ssh - name: Restart ssh
service: name=sshd state=restarted service:
name: sshd
state: restarted
become: True become: True
when: sshd_config.changed when: sshd_config.changed
when: ansible_distribution in common_redhat_variants when: ansible_distribution in common_redhat_variants
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment