Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate SSH key; Run tasks as root; Properly check for correct editor #26

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions course-preparation/Ansible/addis.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
196.223.215.138
196.223.215.139
196.223.215.140
196.223.215.142

[addis:children]
training-lab
22 changes: 22 additions & 0 deletions course-preparation/Ansible/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---

- hosts: 196.223.215.139
become: true
name: Deploy Docker onto your own server
tasks:

- name: Ensure Docker repository key is installed
apt_key:
id: "0EBFCD88"
keyserver: "https://download.docker.com/linux/ubuntu/gpg"
state: present

- name: Ensure docker registry is available
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present

- name: Ensure docker and dependencies are installed
apt:
name: docker-ce
update_cache: yes
155 changes: 155 additions & 0 deletions course-preparation/Ansible/group_vars/addis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,158 @@ participants:
package:
RedHat: vim
Debian: vim
- name: Abdulkarim Msangi # Real name of the person
org: TERNET # Organisation/team they work in
username: abms # username on the lab machine
github: abmsangi@gmail.com # github user account
git: # git configuration on the lab machines
user:
name: abdulkarim msangi
email: abmsangi@gmail.com
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Henry Simfukwe # Real name of the person
org: ZAMREN # Organisation/team they work in
username: chalemba # username on the lab machine
github: chalemba # github user account
git: # git configuration on the lab machines
user:
name: Henry Simfukwe
email: henry.chalemba@gmail.com
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Chris Rohrer # Real name of the person
org: UbuntuNet Alliance # Organisation/team they work in
username: chris # username on the lab machine
github: chrohrer # github user account
git: # git configuration on the lab machines
user:
name: Chris Rohrer
email: chris.rohrer@ubuntunet.net
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Hellen Nakawungu # Real name of the person
org: RENU # Organisation/team they work in
username: hellen # username on the lab machine
github: hellen # github user account
git: # git configuration on the lab machines
user:
name: Hellen Nakawungu
email: hnakawungu@renu.ac.ug
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Josiah Kisoso # Real name of the person
org: UR # Organisation/team they work in
username: josiah.kisoso # username on the lab machine
github: morendat # github user account
git: # git configuration on the lab machines
user:
name: Josiah Kisoso
email: jskisoso@gmail.com
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Joy Otuya # Real name of the person
org: Kenya Education Network # Organisation/team they work in
username: joyotuya # username on the lab machine
github: joyotuya # github user account
git: # git configuration on the lab machines
user:
name: Joy Otuya
email: joyotuya@gmail.com
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Mohamed A. Ali # Real name of the person
org: SomlaiREN # Organisation/team they work in
username: mjarfadhi # username on the lab machine
github: mjarfadhi # github user account
git: # git configuration on the lab machines
user:
name: Mohamed A. Ali
email: ict@psu.edu.so
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Neovaldo Maculuve # Real name of the person
org: MoRENet # Organisation/team they work in
username: neovaldopaulo # username on the lab machine
github: neovaldopaulo # github user account
git: # git configuration on the lab machines
user:
name: Neovaldo Maculuve
email: neovaldopaulo@hotmail.com
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Niry Andriambelo # Real name of the person
org: iRENALA # Organisation/team they work in
username: NyAndria # username on the lab machine
github: NyAndria # github user account
git: # git configuration on the lab machines
user:
name: Niry Andriambelo
email: andriambelo.niry@gmail.com
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Walumbuka Ilundu WAil # Real name of the person
org: MINESU # Organisation/team they work in
username: wail # username on the lab machine
github: wail # github user account
git: # git configuration on the lab machines
user:
name: walumbuka wail
email: ilunduwail@gmail.com
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim
- name: Walu Gondwe # Real name of the person
org: MAREN # Organisation/team they work in
username: walusungu.gondwe # username on the lab machine
github: agondway # github user account
git: # git configuration on the lab machines
user:
name: Walu Gondwe
email: wgondwe@bintelanalytics.mw
core:
editor:
name: vim
package:
RedHat: vim
Debian: vim

114 changes: 75 additions & 39 deletions course-preparation/Ansible/training-lab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,46 @@
include_vars:
file: "group_vars/passwords-{{ site_name }}.yml"

- name: Announce the setup
slack:
domain: ubuntunet.slack.com
token: "{{ slack_token }}"
msg: "Running training-lab setup for {{ inventory_hostname }} at {{ site_name }} :worried: "
channel: "#devops"
username: "Ansible on {{ inventory_hostname }}"
link_names: 1
parse: 'full'
# - name: Announce the setup
# slack:
# domain: ubuntunet.slack.com
# token: "{{ slack_token }}"
# msg: "Running training-lab setup for {{ inventory_hostname }} at {{ site_name }} :worried: "
# channel: "#devops"
# username: "Ansible on {{ inventory_hostname }}"
# link_names: 1
# parse: 'full'

- name: Low down dirty setup
become: true
raw: "apt-get -y install {{ item }}"
with_items: "{{ managed_prerequisites }}"

- name: Announce the outcome
slack:
domain: ubuntunet.slack.com
token: "{{ slack_token }}"
msg: "Running training-lab setup for {{ inventory_hostname }} at {{ site_name }} :ok_hand: "
channel: "#devops"
username: "Ansible on {{ inventory_hostname }}"
link_names: 1
parse: 'full'
# - name: Announce the outcome
# slack:
# domain: ubuntunet.slack.com
# token: "{{ slack_token }}"
# msg: "Running training-lab setup for {{ inventory_hostname }} at {{ site_name }} :ok_hand: "
# channel: "#devops"
# username: "Ansible on {{ inventory_hostname }}"
# link_names: 1
# parse: 'full'

- hosts: training-lab
name: Deploy Ansible onto the lab
tasks:
- name: Pick up sensitive vars
include_vars:
file: "group_vars/passwords-{{ site_name }}.yml"
- name: Announce the Config play
slack:
domain: ubuntunet.slack.com
token: "{{ slack_token }}"
msg: "Running training-lab configuration on {{ inventory_hostname }} at {{ site_name }} :worried: "
channel: "#devops"
username: "Ansible on {{ inventory_hostname }}"
link_names: 1
parse: 'full'
# - name: Announce the Config play
# slack:
# domain: ubuntunet.slack.com
# token: "{{ slack_token }}"
# msg: "Running training-lab configuration on {{ inventory_hostname }} at {{ site_name }} :worried: "
# channel: "#devops"
# username: "Ansible on {{ inventory_hostname }}"
# link_names: 1
# parse: 'full'
- name: Install some basic stuff
become: true
package:
Expand All @@ -67,30 +67,64 @@
name: ansible
state: present

- name: Announce the Config play outcome
slack:
domain: ubuntunet.slack.com
token: "{{ slack_token }}"
msg: "{{ inventory_hostname }} at {{ site_name }} now knows kung-fu :neo:"
channel: "#devops"
username: "Ansible on {{ inventory_hostname }}"
link_names: 1
parse: 'full'
- hosts: training-lab
name: Deploy Docker onto the lab
become: true
tags: docker
tasks:
- name: Allow apt over https
become: true
raw: "apt-get -y install {{ item }}"
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common

- name: Ensure Docker repository key is installed
apt_key:
id: "0EBFCD88"
keyserver: "https://download.docker.com/linux/ubuntu/gpg"
state: present

- name: Ensure docker registry is available
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present

- name: Ensure docker and dependencies are installed
apt:
name: docker-ce
update_cache: yes

# - name: Announce the Config play outcome
# slack:
# domain: ubuntunet.slack.com
# token: "{{ slack_token }}"
# msg: "{{ inventory_hostname }} at {{ site_name }} now knows kung-fu :neo:"
# channel: "#devops"
# username: "Ansible on {{ inventory_hostname }}"
# link_names: 1
# parse: 'full'

# This is a single loop over participants - should be done in a block
- name: Setup the users
hosts: all
tasks:
- name: Add the participant
become: true
user:
name: "{{ item.username }}"
comment: "User added for {{ site_name }} DevOps bootcamp"
state: present
createhome: true
generate_ssh_key: true
generate_ssh_key: false
groups: docker
append: yes
with_items: "{{ participants }}"

- name: Ensure that the participant ssh key on Github is in authorized keys
become: true
authorized_key:
exclusive: no
manage_dir: yes
Expand All @@ -99,10 +133,11 @@
state: present
with_items: "{{ participants }}"

# assert that the preferred package is in the prerequisites ?
# assert that the preferred package is in the prerequisites ?
- name: Assert that the preferred editor is in prerequisites
assert:
that: "{{ item.git.core.package[ansible_os_family ]}} in prerequisites[ansible_os_family]"
that: "'{{ item.git.core.editor.package[ansible_os_family ]}}' in prerequisites[ansible_os_family]"
with_items: "{{ participants }}"

# - name: Ensure that the preferred editor is available
# package:
Expand All @@ -115,3 +150,4 @@
name: core.editor
value: "{{ item.git.core.editor}}"
scope: global
with_items: "{{ participants }}"