SlideShare a Scribd company logo
1 of 19
Download to read offline
Using Ansible
as Makefiles
to unite your
developers
Ansible is mostly used for:
• Provisioning
• Configuration Management
• App Deployment
• Continuous Delivery
• Security & Compliance
• Orchestration

Application
Application
Frontend
Application
Backend
Frontend
Application
Backend
Frontend
Operations
Application
Backend
Frontend
Operations
Why Ansible
instead of
Makefiles?
Readability
BUILD_DIR=../build
# Clean old build(s)
clean:
rm -rf $(BUILD_DIR)
vars:
- build_dir: ../build

tasks:
- name: Clean old build(s)
file:
path: "{{ build_dir }}"
state: absent
Makefile Ansible
BUILD_DIR=../build

SRC_DIR=../src
# Copy all app files
copy-app:
cp -R $(SRC_DIR) $(BUILD_DIR)
vars:
- build_dir: ../build
- src_dir: ../src

tasks:
- name: Copy all app files
copy:
src: "{{ src_dir }}"
dest: "{{ build_dir }}"
Makefile Ansible
BUILD_DIR=../build
# Create symlink of local.xml
symlink-localxml:
ln -fs /path/to/local.xml 
$(BUILD_DIR)/local.xml
vars:
- build_dir: ../build

tasks:
- name: Create symlink of local.xml
file:
src: /path/to/local.xml
dest: "{{ build_dir }}/local.xml”
state: link
Makefile Ansible
BUILD_DIR=../build
SRC_DIR=../src
declare -A APP_DEPENDENCIES=
([“SRC”]=vendor [“DEST"]=vendor) 
([“SRC"]=node_modules/app.js [“DEST”]=js)
# Copy app dependencies (PHP & JS)
copy-dependencies:
for item in "$${!APP_DEPENDENCIES[@]}" ; do 
cp -rT --preserve=mode,timestamp,links 
”./$${item['SRC']}" 
“${BUILD_DIR}/$${item[‘DEST']}"; 
done
vars:
- build_dir: ../build
- app_dependencies:
- { src: vendor, dest: vendor }
- { src: node_modules/app.js, dest: js }

tasks:
- name: Copy app dependencies (PHP & JS)
copy:
src: "./{{ item.src }}"
dest: "{{ build_dir }}{{ item.dest }}"
follow: yes
with_items: app_dependencies
Makefile Ansible
Not sure if that works,
Makefiles are complex indeed ;D
BUILD_DIR=../build
SRC_DIR=../src
declare -A APP_DEPENDENCIES=
([“SRC"]=vendor ["DEST"]=vendor) 
(["SRC"]=node_modules/app.js ["DEST"]=js)
# Clean old build(s)
clean:
rm -rf $(BUILD_DIR)
# Copy all app files
copy-app:
cp -R $(SRC_DIR) $(BUILD_DIR)
# Create local.xml symlink
symlink-localxml:
ln -fs /path/to/local.xml 
$(BUILD_DIR)/local.xml
# Copy app dependencies (PHP & JS)
copy-dependencies:
for item in "$${!APP_DEPENDENCIES[@]}" ; do 
cp -rT --preserve=mode,timestamp,links 
”./$${item['SRC']}" 
“${BUILD_DIR}/$${item['DEST']}" ; 
done
vars:
- build_dir: ../build
- src_dir: ../src
- app_dependencies:
- { src: vendor, dest: vendor }
- { src: node_modules/app.js, dest: js }
tasks:
- name: Clean old build(s)
file:
path: "{{ build_dir }}"
state: absent
- name: Copy all app files
copy:
src: "{{ src_dir }}"
dest: "{{ build_dir }}"
- name: Create local.xml symlink
file:
src: /path/to/local.xml
dest: "{{ build_dir }}/local.xml”
state: link
- name: Copy app dependencies (PHP & JS)
copy:
src: "./{{ item.src }}"
dest: "{{ build_dir }}{{ item.dest }}"
follow: yes
with_items: app_dependencies
Makefile Ansible
Questions ?
Thank you ;D
@thiagoalessio
github.com/thiagoalessio

More Related Content

What's hot

Put a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going FastPut a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going Fast
OSCON Byrum
 

What's hot (20)

Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...
Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...
Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...
 
Cocoa on-rails-3rd
Cocoa on-rails-3rdCocoa on-rails-3rd
Cocoa on-rails-3rd
 
Dev streams2
Dev streams2Dev streams2
Dev streams2
 
Building RESTful APIs w/ Grape
Building RESTful APIs w/ GrapeBuilding RESTful APIs w/ Grape
Building RESTful APIs w/ Grape
 
What's New in v2 - AnsibleFest London 2015
What's New in v2 - AnsibleFest London 2015What's New in v2 - AnsibleFest London 2015
What's New in v2 - AnsibleFest London 2015
 
REST API for your WP7 App
REST API for your WP7 AppREST API for your WP7 App
REST API for your WP7 App
 
HTML5 addressbook
HTML5 addressbookHTML5 addressbook
HTML5 addressbook
 
Running Docker on AWS
Running Docker on AWSRunning Docker on AWS
Running Docker on AWS
 
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
 
Xcode Server & Xcode 7 Bots
Xcode Server & Xcode 7 Bots Xcode Server & Xcode 7 Bots
Xcode Server & Xcode 7 Bots
 
Building an API using Grape
Building an API using GrapeBuilding an API using Grape
Building an API using Grape
 
Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.
 
20180618 wwdc cherrypick_xcode10beta
20180618 wwdc cherrypick_xcode10beta20180618 wwdc cherrypick_xcode10beta
20180618 wwdc cherrypick_xcode10beta
 
Class.devops.chapter.1.intro
Class.devops.chapter.1.introClass.devops.chapter.1.intro
Class.devops.chapter.1.intro
 
Rails 3.1 sneak peak
Rails 3.1 sneak peakRails 3.1 sneak peak
Rails 3.1 sneak peak
 
Windows Containers - Microsoft Ignite The Tour
Windows Containers - Microsoft Ignite The TourWindows Containers - Microsoft Ignite The Tour
Windows Containers - Microsoft Ignite The Tour
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine Patterns
 
Ultimate Productivity Tools
Ultimate Productivity ToolsUltimate Productivity Tools
Ultimate Productivity Tools
 
Put a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going FastPut a Button on It: Removing Barriers to Going Fast
Put a Button on It: Removing Barriers to Going Fast
 
Elixir と Maru で REST API
Elixir と Maru で REST APIElixir と Maru で REST API
Elixir と Maru で REST API
 

Similar to Using Ansible as Makefiles to unite your developers

Complet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docxComplet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docx
ardhowp
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
Jace Ju
 

Similar to Using Ansible as Makefiles to unite your developers (20)

What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
 
Complet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docxComplet vector.dep.inc# This code depends on make tool being .docx
Complet vector.dep.inc# This code depends on make tool being .docx
 
Dethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsDethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.js
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
 
Deploying Your Webapps (with Capistrano)
Deploying Your Webapps (with Capistrano)Deploying Your Webapps (with Capistrano)
Deploying Your Webapps (with Capistrano)
 
Container Support in IBM Spectrum LSF
Container Support in IBM Spectrum LSFContainer Support in IBM Spectrum LSF
Container Support in IBM Spectrum LSF
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
 
DockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best PracticesDockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best Practices
 
DCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best PracticesDCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best Practices
 
Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?
 
Ant
AntAnt
Ant
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Node Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsNode Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.js
 
Codefresh + Cloud 66 webinar: Testing Strategies for Docker Driven Development
Codefresh + Cloud 66 webinar: Testing Strategies for Docker Driven DevelopmentCodefresh + Cloud 66 webinar: Testing Strategies for Docker Driven Development
Codefresh + Cloud 66 webinar: Testing Strategies for Docker Driven Development
 
London Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.jsLondon Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.js
 
Makefiles in 2020 — Why they still matter
Makefiles in 2020 — Why they still matterMakefiles in 2020 — Why they still matter
Makefiles in 2020 — Why they still matter
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Provisioning, deploying and debugging node.js applications on azure
Provisioning, deploying and debugging node.js applications on azureProvisioning, deploying and debugging node.js applications on azure
Provisioning, deploying and debugging node.js applications on azure
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 

Recently uploaded (20)

A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and Prevention
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityAPVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 

Using Ansible as Makefiles to unite your developers

  • 1. Using Ansible as Makefiles to unite your developers
  • 2. Ansible is mostly used for: • Provisioning • Configuration Management • App Deployment • Continuous Delivery • Security & Compliance • Orchestration

  • 8.
  • 9.
  • 10.
  • 13. BUILD_DIR=../build # Clean old build(s) clean: rm -rf $(BUILD_DIR) vars: - build_dir: ../build
 tasks: - name: Clean old build(s) file: path: "{{ build_dir }}" state: absent Makefile Ansible
  • 14. BUILD_DIR=../build
 SRC_DIR=../src # Copy all app files copy-app: cp -R $(SRC_DIR) $(BUILD_DIR) vars: - build_dir: ../build - src_dir: ../src
 tasks: - name: Copy all app files copy: src: "{{ src_dir }}" dest: "{{ build_dir }}" Makefile Ansible
  • 15. BUILD_DIR=../build # Create symlink of local.xml symlink-localxml: ln -fs /path/to/local.xml $(BUILD_DIR)/local.xml vars: - build_dir: ../build
 tasks: - name: Create symlink of local.xml file: src: /path/to/local.xml dest: "{{ build_dir }}/local.xml” state: link Makefile Ansible
  • 16. BUILD_DIR=../build SRC_DIR=../src declare -A APP_DEPENDENCIES= ([“SRC”]=vendor [“DEST"]=vendor) ([“SRC"]=node_modules/app.js [“DEST”]=js) # Copy app dependencies (PHP & JS) copy-dependencies: for item in "$${!APP_DEPENDENCIES[@]}" ; do cp -rT --preserve=mode,timestamp,links ”./$${item['SRC']}" “${BUILD_DIR}/$${item[‘DEST']}"; done vars: - build_dir: ../build - app_dependencies: - { src: vendor, dest: vendor } - { src: node_modules/app.js, dest: js }
 tasks: - name: Copy app dependencies (PHP & JS) copy: src: "./{{ item.src }}" dest: "{{ build_dir }}{{ item.dest }}" follow: yes with_items: app_dependencies Makefile Ansible Not sure if that works, Makefiles are complex indeed ;D
  • 17. BUILD_DIR=../build SRC_DIR=../src declare -A APP_DEPENDENCIES= ([“SRC"]=vendor ["DEST"]=vendor) (["SRC"]=node_modules/app.js ["DEST"]=js) # Clean old build(s) clean: rm -rf $(BUILD_DIR) # Copy all app files copy-app: cp -R $(SRC_DIR) $(BUILD_DIR) # Create local.xml symlink symlink-localxml: ln -fs /path/to/local.xml $(BUILD_DIR)/local.xml # Copy app dependencies (PHP & JS) copy-dependencies: for item in "$${!APP_DEPENDENCIES[@]}" ; do cp -rT --preserve=mode,timestamp,links ”./$${item['SRC']}" “${BUILD_DIR}/$${item['DEST']}" ; done vars: - build_dir: ../build - src_dir: ../src - app_dependencies: - { src: vendor, dest: vendor } - { src: node_modules/app.js, dest: js } tasks: - name: Clean old build(s) file: path: "{{ build_dir }}" state: absent - name: Copy all app files copy: src: "{{ src_dir }}" dest: "{{ build_dir }}" - name: Create local.xml symlink file: src: /path/to/local.xml dest: "{{ build_dir }}/local.xml” state: link - name: Copy app dependencies (PHP & JS) copy: src: "./{{ item.src }}" dest: "{{ build_dir }}{{ item.dest }}" follow: yes with_items: app_dependencies Makefile Ansible