Last active
March 21, 2020 15:17
-
-
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/
This file contains hidden or 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
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 |
This file contains hidden or 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: ssh distribution specific handler | |
include: "{{ ansible_distribution }}{{ ansible_distribution_version }}.yml" |
This file contains hidden or 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: "{{ sshd_service_restart_id }}" | |
service: | |
name={{ sshd_service }} | |
state=restarted | |
enabled=yes |
This file contains hidden or 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: 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 }}" |
This file contains hidden or 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 sshd for Ubuntu14.04 | |
apt: | |
name={{ sshd_pkg }} | |
update_cache=yes |
This file contains hidden or 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
--- | |
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