Amazon EC2
aws ec2 run-instances
--image-id ami-12345678
--instance-type t3.micro
--user-data file://script.yamlSets up GitLab CE for Git repository management and CI/CD
#cloud-config
package_update: true
package_upgrade: true
packages:
- curl
- openssh-server
- ca-certificates
- tzdata
- perl
- postfix
write_files:
- path: /etc/gitlab/gitlab.rb
content: |
external_url 'http://gitlab.localhost'
# PostgreSQL settings
postgresql['shared_preload_libraries'] = 'pg_stat_statements'
# Redis settings
redis['bind'] = '127.0.0.1'
redis['port'] = 6379
# Gitaly settings
gitaly['configuration'] = {
storage: [
{
name: 'default',
path: '/var/opt/gitlab/git-data/repositories',
},
],
}
# Disable components we don't need
prometheus_monitoring['enable'] = false
alertmanager['enable'] = false
node_exporter['enable'] = false
redis_exporter['enable'] = false
postgres_exporter['enable'] = false
gitlab_exporter['enable'] = false
grafana['enable'] = false
# Email settings
gitlab_rails['smtp_enable'] = false
runcmd:
# Configure SSH
- systemctl enable ssh
- systemctl start ssh
# Configure Postfix
- debconf-set-selections <<< "postfix postfix/mailname string localhost"
- debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
- systemctl enable postfix
- systemctl start postfix
# Install GitLab
- curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | bash
- EXTERNAL_URL="http://gitlab.localhost" apt-get install -y gitlab-ce
# Configure GitLab
- gitlab-ctl reconfigure
# Configure firewall
- ufw allow http
- ufw allow https
- ufw allow ssh
# Get initial root password
- sleep 60
- echo "GitLab root password:"
- cat /etc/gitlab/initial_root_password
- echo "GitLab available at http://gitlab.localhost"aws ec2 run-instances
--image-id ami-12345678
--instance-type t3.micro
--user-data file://script.yamldoctl compute droplet create
--image ubuntu-22-04-x64
--size s-1vcpu-1gb
--user-data-file script.yaml
my-dropletgcloud compute instances create
my-instance
--metadata-from-file
user-data=script.yaml