$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ansible and Scala Projects
Search
Shannon
May 30, 2019
Technology
0
250
Ansible and Scala Projects
Shannon
May 30, 2019
Tweet
Share
More Decks by Shannon
See All by Shannon
Signify Bootcamp
signify
0
250
Event Sourcing Blockchains at TokenAnalyst
signify
0
130
The Last Frontier and Beyond
signify
0
120
Jon Pither
signify
0
240
How to write like Cats
signify
0
240
Kubernetes as a Streaming Data Platform with Kafka, Spark, and Scala
signify
0
75
Writing human readable tests using Scala
signify
0
140
Making Contracts Smart, Secure and Functional with DAML and Scala
signify
0
110
Automatic differentiation in Scala by Xiayun Sun
signify
0
360
Other Decks in Technology
See All in Technology
「品質とスピードはトレード・オンできる」に向き合い続けた2年半を振り返る / Quality and speed can be traded on.
mii3king
0
470
【Oracle Cloud ウェビナー】【入門&再入門】はじめてのOracle Cloud Infrastructure [+最新情報]
oracle4engineer
PRO
2
200
RAMP2024
takeyukitamura
3
240
Amazon CloudFrontを活用したゼロダウンタイム実現する安定的なデプロイメント / 20241129 Yoshiki Shinagawa
shift_evolve
0
130
Empowering Customer Decisions with Elasticsearch: From Search to Answer Generation
hinatades
PRO
0
190
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
140
今はまだ小さい東京ガス内製開発チームが、これからもKubernetesと共に歩み続けるために
yussugi
3
540
クラウドネイティブなNewSQLで実現するミッションクリティカルなアプリケーションの運用
yuyu_hf
PRO
1
160
12/3(火)のBedrockアプデ速報(re:Invent 2024 Daily re:Cap #2 with AWS Heroes)
minorun365
PRO
4
100
Entra ID の多要素認証(Japan Microsoft 365 コミュニティ カンファレンス 2024 )
murachiakira
0
1.8k
徹底解説!Microsoft 365 Copilot の拡張機能 / Complete guide to Microsoft 365 Copilot extensions
karamem0
1
1.7k
大規模トラフィックを支える ゲームバックエンドの課題と構成の変遷 ~安定したゲーム体験を実現するために~
colopl
0
870
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Designing Experiences People Love
moore
138
23k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
4 Signs Your Business is Dying
shpigford
181
21k
The Pragmatic Product Professional
lauravandoore
32
6.3k
RailsConf 2023
tenderlove
29
920
How to Think Like a Performance Engineer
csswizardry
21
1.2k
The Invisible Side of Design
smashingmag
298
50k
Transcript
Ansible for Scala projects José Miguel 0pt1mates | @jm2dev 1
/ 39
Introducción ▶ Who am I? ▶ What do I do?
0pt1mates | @jm2dev 2 / 39
What do I want Make everything as simpler as possible,
but not simpler. Albert Einstein 0pt1mates | @jm2dev 3 / 39
Motivation ▶ Don’t repeat yourself ▶ Knwoledge sharing 0pt1mates |
@jm2dev 4 / 39
A definition Automated provisioning, also called self-service provision- ing, is
the ability to deploy an information technology or telecommunications service by using predefined proce- dures that are carried out electronically without requiring human intervention. 0pt1mates | @jm2dev 5 / 39
Options ▶ ansible ▶ cfengine ▶ chef ▶ puppet ▶
salt 0pt1mates | @jm2dev 6 / 39
Ansible ▶ Simple requisites ▶ ssh ▶ python ▶ Simple
language ▶ yaml 0pt1mates | @jm2dev 7 / 39
Setup ▶ python 3 with virtualenv mkdir proyecto cd proyecto
python3 -m venv venv 0pt1mates | @jm2dev 8 / 39
cat requirements.txt ansible 0pt1mates | @jm2dev 9 / 39
Inventario: cat hosts [local] 127.0.0.1 0pt1mates | @jm2dev 10 /
39
Tasks for a dev ▶ software installation ▶ copy files
▶ etc Our requirements for a Scala project: ▶ git ▶ openjdk ▶ sbt 0pt1mates | @jm2dev 11 / 39
Role ▶ Group tasks. mkdir -p roles/programador/tasks touch roles/programador/tasks/main.yml 0pt1mates
| @jm2dev 12 / 39
cat programador/tasks/main.yml --- - name: Update pacman cache become: true
pacman: update_cache: yes - name: Install packages become: true pacman: name: "{{ item }}" state: present 0pt1mates | @jm2dev 13 / 39
cat programador.yml --- - name: Preparacion proyecto X hosts: local
connection: local roles: - programador 0pt1mates | @jm2dev 14 / 39
Does it work? cd proyecto source venv/bin/activate pip install -r
requirements.txt ansible-playbook -i hosts programador.yml 0pt1mates | @jm2dev 15 / 39
Role per project ▶ barebone project ▶ more things to
automate? 0pt1mates | @jm2dev 16 / 39
Tasks version 2 Let’s clean in it a bit mv
roles/programador/tasks/main.yml \ roles/programador/tasks/paquetes.yml 0pt1mates | @jm2dev 17 / 39
cat roles/programador/tasks/sbt.yml --- - name: SBT config plugins directory file:
path: "{{ home_dir }}/.sbt/1.0/plugins" recurse: yes state: directory mode: 0755 - name: SBT Global plugins copy: src: files/plugins.sbt 0pt1mates | @jm2dev 18 / 39
Those variables touch group_vars/all --- home_dir: "{{ lookup('env', 'HOME') }}"
0pt1mates | @jm2dev 19 / 39
Configuring SBT (II) mkdir -p roles/programador/files touch roles/programador/files/plugins.sbt touch roles/programador/files/repositories.sbt
0pt1mates | @jm2dev 20 / 39
cat roles/programador/files/plugins.sbt addSbtPlugin("org.ensime" % "sbt-ensime" % "2.1.0") addSbtPlugin("io.get-coursier" % "sbt-coursier"
% "1.1.0-M1 addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") 0pt1mates | @jm2dev 21 / 39
cat roles/programador/files/repositories.sbt [repositories] local my-ivy-proxy-releases: https://nexus.proyecto.xyz/content [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sb my-maven-proxy-releases: https://nexus.proyecto.xyz/conte 0pt1mates
| @jm2dev 22 / 39
cat roles/programador/tasks/git.yml --- - name: Git config directory file: path:
"{{ home_dir }}/.config/git" state: directory mode: 0755 - name: Git setup template: src: templates/git_config.j2 dest: "{{ home_dir }}/.config/git/config" 0pt1mates | @jm2dev 23 / 39
Configuring GIT (II) What are templates? mkdir -p roles/programador/templates touch
roles/programador/templates/git_config.j2 0pt1mates | @jm2dev 24 / 39
cat roles/programador/templates/gitconfig .j2 [user] name = {{ git_username }} email
= {{ git_email }} [color] ui = auto [push] default = simple [core] 0pt1mates | @jm2dev 25 / 39
Configuring GIT (IV) And those are … variables? mkdir -p
roles/programador/vars touch roles/programador/vars/main.yml 0pt1mates | @jm2dev 26 / 39
cat roles/programador/vars/main.yml --- git_username: Jose Miguel Martinez Carrasco git_email:
[email protected]
0pt1mates | @jm2dev 27 / 39
Developer tasks (II) And the new main.yml version: --- -
import_tasks: paquetes.yml - import_tasks: git.yml - import_tasks: sbt.yml 0pt1mates | @jm2dev 28 / 39
Porject X role ▶ simple & functional setup ▶ extensible
0pt1mates | @jm2dev 29 / 39
Tasks mkdir -p roles/proyectoX/tasks touch roles/proyectoX/tasks/main.yml touch roles/proyectoX/tasks/database.yml --- -
import_tasks: database.yml 0pt1mates | @jm2dev 30 / 39
A database --- - name: Update pacman cache become: true
pacman: update_cache: yes - name: Install postgresql become: true pacman: name: "{{ item }}" state: present 0pt1mates | @jm2dev 31 / 39
Fatjar ▶ package our service as a fatjar ▶ run
it locally as a service so we can ▶ run integration/acceptance tests 0pt1mates | @jm2dev 32 / 39
Systemd unit mkdir -p roles/fatjar/{tasks,templates,vars} touch roles/fatjar/tasks/main.yml touch roles/fatjar/templates/fatjar.service.j2 touch
roles/fatjar/vars/all 0pt1mates | @jm2dev 33 / 39
cat roles/fatjar/vars/all service_user: "hello" service_name: "Hello" service_install_dir: "/opt/{{ service_name }}"
bin_location: "{{ service_install_dir }}/bin/server" 0pt1mates | @jm2dev 34 / 39
cat roles/fatjar/templates/fatjar.service.j2 [Unit] Description={{ service_name }} After=syslog.target [Service] ExecStart={{ bin_location
}} User={{ service_user }} [Install] WantedBy=multi-user.target 0pt1mates | @jm2dev 35 / 39
cat roles/fatjar/tasks/main.yml - name: Create systemd directory file: path: "{{
service_install }}" state: directory mode: 0755 - name: Install fatjar service copy: src: "item" dest: "{{ service_install }}" with_items: 0pt1mates | @jm2dev 36 / 39
Playbook --- - name: Preparacion proyecto X hosts: local connection:
local roles: - programador - proyectoX - fatjar 0pt1mates | @jm2dev 37 / 39
Finally curl localhost:8080/hello/scalaInTheCity { "message": "Hello, Scala in the City"
} 0pt1mates | @jm2dev 38 / 39
Contact @jm2dev 0pt1mates | @jm2dev 39 / 39