Skip to content

Commit ae6aa83

Browse files
committed
[WIP] begin gitlab autoscaling
1 parent e58d8cb commit ae6aa83

26 files changed

+1467
-13
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trim_trailing_whitespace = false
1414
[*.yml]
1515
indent_size = 2
1616

17-
[*.json]
17+
[*.{json,tf}]
1818
indent_size = 2
1919

2020
[Makefile]

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
ami_config.json
1+
/packer/config.json
2+
/terraform/terraform.tfvars
3+
/terraform/terraform.tfstate
4+
/terraform/terraform.tfstate.backup

Makefile

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,36 @@ ENV = /usr/bin/env
1010
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
1111
default: all; # default target
1212

13-
.PHONY: all config
13+
.PHONY: all config ami ami-gitlab ami-runner plan apply output destroy
1414

1515
all:
1616

1717
config:
18-
cp -n -v ami_config.dist.json ami_config.json
18+
cp -n -v packer/config.dist.json packer/config.json
19+
cp -n -v terraform/terraform.dist.tfvars terraform/terraform.tfvars
20+
21+
ami: ami-gitlab ami-runner
1922

2023
ami-gitlab: config
21-
# packer -var-file=
24+
cd packer
25+
packer build -var-file=config.json gitlab.json
26+
27+
ami-runner: config
28+
cd packer
29+
packer build -var-file=config.json gitlab-ci-runner.json
30+
31+
plan: config
32+
cd terraform
33+
terraform plan
34+
35+
apply: config
36+
cd terraform
37+
terraform apply
38+
39+
output: config
40+
cd terraform
41+
terraform output
42+
43+
destroy: config
44+
cd terraform
45+
terraform destroy
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: gitlab-ci runner install
3+
hosts: gitlab-ci-runners
4+
connection: local
5+
become: yes
6+
become_method: sudo
7+
8+
roles:
9+
- packages
10+
- locales
11+
- account
12+
- docker
13+
- aws
14+
- gitlab-runner

packer/ansible/gitlab.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: gitlab install
3+
hosts: gitlab
4+
connection: local
5+
become: yes
6+
become_method: sudo
7+
8+
roles:
9+
- packages
10+
- locales
11+
- nfs
12+
- aws
13+
- account
14+
- gitlab

packer/ansible/group_vars/all.yml

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
locale_generate:
3+
- { lang: 'en_US', charset: 'UTF-8' }
4+
- { lang: 'fr_FR', charset: 'UTF-8' }
5+
6+
locale_timezone_continent: Etc
7+
locale_timezone_city: UTC
8+
9+
locale_default_lang: en_US
10+
locale_default_charset: UTF-8
11+
#
12+
# network_hostname: 'vagrant.vm'
13+
# network_hosts:
14+
# -
15+
# ip: '127.0.0.1'
16+
# names: ['vagrant', 'vagrant.localhost', 'vagrant.local', 'vagrant.localhost.com', 'vagrant.local.com']
17+
#
18+
network_dns_resolv_reconfigure: false
19+
# network_resolv_nameservers:
20+
# - '8.8.8.8'
21+
# - '8.8.4.4'
22+
#
23+
network_interfaces_reconfigure: false
24+
network_interfaces_restart: false
25+
# network_interfaces:
26+
# enp0s3:
27+
# comment: The primary network interface
28+
# general_options:
29+
# 'pre-up': 'sleep 2'
30+
# allow: []
31+
# type: dhcp
32+
# options: {}
33+
#
34+
# sudo_files:
35+
# - { sudogroup: 'vagrant', command_user: 'ALL', nopasswd_commands: ['ALL'] }
36+
#
37+
account_groups:
38+
ubuntu: {}
39+
# gid: 1000
40+
# system: false
41+
# docker:
42+
# gid: 998
43+
# system: true
44+
45+
account_users:
46+
ubuntu:
47+
name: ubuntu
48+
# comment: 'ubuntu admin user'
49+
group: ubuntu
50+
groups:
51+
- adm
52+
- dialout
53+
- cdrom
54+
- floppy
55+
- sudo
56+
- audio
57+
- dip
58+
- video
59+
- plugdev
60+
- netdev
61+
- lxd
62+
# uid: 1000
63+
config_files:
64+
-
65+
src: home/{{ ansible_os_family|lower }}/.bashrc.j2
66+
dest: .bashrc
67+
backup: yes
68+
force: yes
69+
-
70+
src: home/.bash_aliases.j2
71+
dest: .bash_aliases
72+
backup: yes
73+
force: yes
74+
-
75+
src: home/.zshrc.j2
76+
dest: .zshrc
77+
backup: yes
78+
force: yes
79+
-
80+
src: etc/skel/.git-prompt-colors.sh.j2
81+
dest: .git-prompt-colors.sh
82+
backup: yes
83+
force: no
84+
-
85+
src: etc/skel/.gitconfig.j2
86+
dest: .gitconfig
87+
backup: yes
88+
force: no
89+
-
90+
src: etc/skel/.gitignore.j2
91+
dest: .gitignore
92+
backup: yes
93+
force: no
94+
gitconfig: []
95+
# - { name: 'user.name', option: 'Martin Dupond'}
96+
# - { name: 'user.email', option: 'martin.dupond@example.com'}
97+
bash_aliases: {}
98+
# <alias>: <command>
99+
#
100+
# account_env_vars:
101+
# vagrant: {}
102+
# # <username>:
103+
# # <key>: <value>
104+
#
105+
# account_user_passwords:
106+
# vagrant: vagrant
107+
#
108+
# account_url_authorized_keys:
109+
# -
110+
# name: vagrant
111+
# urls:
112+
# - 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub'
113+
#
114+
# samba_users:
115+
# vagrant: vagrant
116+
#
117+
# # samba_shares:
118+
# # -
119+
# # name: share
120+
# # path: /home/vagrant/share
121+
# # owner: vagrant
122+
# # group: vagrant
123+
#
124+
# # nfs_exports_enabled: true
125+
# # nfs_exports:
126+
# # -
127+
# # path: /home/vagrant/share
128+
# # default_options: []
129+
# # clients:
130+
# # -
131+
# # host: '10.0.2.0/24'
132+
# # options:
133+
# # - rw
134+
# # - async
135+
# # - all_squash
136+
# # - 'anonuid=1000'
137+
# # - 'anongid=1000'
138+
# # - no_subtree_c‌​heck
139+
# # -
140+
# # host: '192.168.0.0/16'
141+
# # options:
142+
# # - rw
143+
# # - async
144+
# # - all_squash
145+
# # - 'anonuid=1000'
146+
# # - 'anongid=1000'
147+
# # - no_subtree_c‌​heck
148+
#
149+
# docker_allowed_user:
150+
# - vagrant
151+
152+
apt_sources_replace: false
153+
apt_update_boot: true
154+
apt_upgrade: true
155+
apt_upgrade_type: full
156+
apt_extra_packages:
157+
- linux-generic
158+
- linux-headers-generic
159+
- "linux-headers-{{ ansible_kernel }}"
160+
- "linux-image-extra-{{ ansible_kernel }}"
161+
- dkms
162+
- openssh-blacklist
163+
- openssh-blacklist-extra
164+
- openssl-blacklist
165+
- openssl-blacklist-extra
166+
- git-extras
167+
- zsh
168+
- jq
169+
170+
aws_eb_cli_enabled: false
171+
aws_ecs_cli_enabled: false
172+
173+
python_pip2_packages:
174+
- { name: 'jinja2-cli[yaml]'}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
account_groups:
3+
ubuntu: {}
4+
# gid: 1000
5+
# system: false
6+
docker:
7+
gid: 998
8+
system: true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
File renamed without changes.

packer/gitlab-ci-runner.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"variables": {
3+
"aws_access_key": "",
4+
"aws_secret_key": "",
5+
"aws_region": "eu-west-1"
6+
},
7+
"builders": [
8+
{
9+
"type": "amazon-ebs",
10+
"access_key": "{{ user `aws_access_key` }}",
11+
"secret_key": "{{ user `aws_secret_key` }}",
12+
"region": "{{ user `aws_region` }}",
13+
"source_ami": "ami-81f8d4e7",
14+
"instance_type": "t2.micro",
15+
"ssh_username": "ubuntu",
16+
"ami_name": "gitlab-ci-runner-{{isotime \"20060102\"}}",
17+
"ami_description": "Gitlab CI runner",
18+
"tags": {
19+
"application": "gitlab-ci-runner",
20+
"version": "1.11.1",
21+
"os": "ubuntu",
22+
"os_release": "16.04"
23+
}
24+
}
25+
],
26+
"provisioners": [
27+
{
28+
"type": "shell",
29+
"script": "scripts/ansible.sh"
30+
},
31+
{
32+
"type": "ansible-local",
33+
"extra_arguments": ["-vv"],
34+
"playbook_dir": "ansible",
35+
"group_vars": "ansible/group_vars",
36+
"inventory_groups": "gitlab-ci-runners",
37+
"playbook_file": "ansible/gitlab-ci-runner.yml",
38+
"role_paths": [
39+
"../roles/account",
40+
"../roles/aws",
41+
"../roles/network",
42+
"../roles/docker",
43+
"../roles/gitlab-runner",
44+
"../roles/locales",
45+
"../roles/network",
46+
"../roles/nfs",
47+
"../roles/packages",
48+
"../roles/python",
49+
"../roles/sshd"
50+
]
51+
}
52+
]
53+
}

0 commit comments

Comments
 (0)