Skip to content

Instantly share code, notes, and snippets.

@fishi0x01
Last active March 21, 2020 15:17
Show Gist options
  • Save fishi0x01/6a1a139e821af26e8d2bbfb71a7b37c2 to your computer and use it in GitHub Desktop.
Save fishi0x01/6a1a139e821af26e8d2bbfb71a7b37c2 to your computer and use it in GitHub Desktop.
Snippets for ansible role structuring. Code for blog post https://fishi.devtail.io/weblog/2016/06/02/ansible-role-structuring/
sshd_port: 5133
sshd_groups:
- name: devops
ssh:
allow_tcp_fwd: True
allow_agent_fwd: True
x11_fwd: True
- name: developers
ssh:
allow_tcp_fwd: True
allow_agent_fwd: True
x11_fwd: True
- name: qa
ssh:
allow_tcp_fwd: True
allow_agent_fwd: False
x11_fwd: False
---
- name: ssh distribution specific handler
include: "{{ ansible_distribution }}{{ ansible_distribution_version }}.yml"
---
- name: "{{ sshd_service_restart_id }}"
service:
name={{ sshd_service }}
state=restarted
enabled=yes
---
- name: ssh distribution specific vars
include_vars: "{{ ansible_distribution }}{{ ansible_distribution_version }}.yml"
- name: ssh distribution specific install
include: "{{ ansible_distribution }}{{ ansible_distribution_version }}.yml"
- name: Add sshd_config
template:
src={{ sshd_config_template }}
dest={{ sshd_config_dest }}
owner={{ sshd_config_owner }}
group={{ sshd_config_group }}
mode={{ sshd_config_mode }}
notify: "{{ sshd_service_restart_id }}"
vars:
all_groups: "{{ sshd_groups }}"
---
- name: Install sshd for Ubuntu14.04
apt:
name={{ sshd_pkg }}
update_cache=yes
---
sshd_service: "ssh"
sshd_pkg: "openssh-server"
sshd_config_dest: "/etc/ssh/sshd_config"
sshd_config_owner: "root"
sshd_config_group: "root"
sshd_config_mode: "644"
sshd_config_template: "Ubuntu14_04.sshd_config.j2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment