circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *or*...
TRANSCRIPT
![Page 1: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/1.jpg)
automated deployments from githubwith circleci & ansible
https://github.com/shortstack/circleci-demo-ermahgerd
![Page 2: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/2.jpg)
![Page 3: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/3.jpg)
the plan
1. push to github
2. build in circleci
3. deploy via circleci + awscli *OR* circleci + ansible
srsly -->
![Page 4: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/4.jpg)
things you’ll need
● github account
● static content in a repo in said github account
● circleci account (can auth with github)
● AWS access keys
○ if deploying to AWS*
● SSH key pair
○ if deploying to a server*
![Page 5: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/5.jpg)
pick one
![Page 6: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/6.jpg)
set up circleci
● log into circleci → add projects → set up project
● pick OS and language
● make a .circleci directory in your repo
● touch .circleci/config.yml
● git commit -a
● git push origin master
● click start building
● FYI, this will probably fail
● BUT THAT’S OK! \o/
![Page 7: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/7.jpg)
if using S3...
![Page 8: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/8.jpg)
configure aws
● if you already have access keys with at least S3 permissions,
skip this
● if you don’t…○ log into AWS IAM → users
○ add user
○ name + programmatic access
○ permissions → “attach existing policies”
■ S3 full access
○ create user
○ download keys, keep somewhere safe
![Page 9: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/9.jpg)
configure aws in circleci
● project settings
● AWS permissions
● add access keys
![Page 10: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/10.jpg)
deploying to S3
● make an S3 bucket
● properties → static website → use this to host a website
![Page 11: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/11.jpg)
deploying to S3
config.yml
![Page 12: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/12.jpg)
if using your own server instead of S3...
![Page 13: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/13.jpg)
add user & ssh key
● ssh you@server
sudo useradd circlecisudo chown circleci:circleci /var/www/htmlsu - circlecissh-keygen -t rsa -b 4096cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keyschmod 644 ~/.ssh/authorized_keys
![Page 14: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/14.jpg)
configure ssh
● circleci → project settings
● SSH permissions
● add SSH key
○ set hostname
○ paste private key (.ssh/id_rsa contents)
![Page 15: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/15.jpg)
install python
● sudo apt or yum install python -y
![Page 16: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/16.jpg)
environment variables
● circleci → project settings
● environment variables
● add variable○ ANSIBLE_HOSTS = ~/repo-name/.circleci/hosts
○ ANSIBLE_HOST_KEY_CHECKING = False
![Page 17: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/17.jpg)
configure ansible
● this is your ansible inventory
● .circleci/hosts
![Page 18: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/18.jpg)
deploying to a server
● this assumes you already have a web server running
○ install web server package(s)
○ start and enable web server
○ locate default directory to put content in
○ chown circleci:circleci /directory
![Page 19: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/19.jpg)
deploying to a server
ansible playbook - deploy.ymlconfig.yml
![Page 20: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/20.jpg)
now what?!
![Page 21: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/21.jpg)
let’s test it out
● git commit & git push
● go to circleci dashboard
● SEE WHAT HAPPENS
![Page 22: circleci-demo-ermahgerd automated deployments from github · 3. deploy via circleci + awscli *OR* circleci + ansible srsly --> things you’ll need github account static content in](https://reader033.vdocument.in/reader033/viewer/2022051913/60049c24e7ea447c4167fa86/html5/thumbnails/22.jpg)
the end <3