using ansible as makefiles to unite your developers

19
Using Ansible as Makefiles to unite your developers

Upload: thiago-alessio-pereira

Post on 09-Jan-2017

212 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Using Ansible as Makefiles to unite your developers

Using Ansibleas Makefiles

to unite your developers

Page 2: Using Ansible as Makefiles to unite your developers

Ansible is mostly used for:

• Provisioning • Configuration Management • App Deployment • Continuous Delivery • Security & Compliance • Orchestration

Page 3: Using Ansible as Makefiles to unite your developers

Application

Page 4: Using Ansible as Makefiles to unite your developers

ApplicationFrontend

Page 5: Using Ansible as Makefiles to unite your developers

ApplicationBackend

Frontend

Page 6: Using Ansible as Makefiles to unite your developers

ApplicationBackend

Frontend

Operations

Page 7: Using Ansible as Makefiles to unite your developers

ApplicationBackend

Frontend

Operations

Page 8: Using Ansible as Makefiles to unite your developers
Page 9: Using Ansible as Makefiles to unite your developers
Page 10: Using Ansible as Makefiles to unite your developers
Page 11: Using Ansible as Makefiles to unite your developers

Why Ansibleinstead of

Makefiles?

Page 12: Using Ansible as Makefiles to unite your developers

Readability

Page 13: Using Ansible as Makefiles to unite your developers

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

Page 14: Using Ansible as Makefiles to unite your developers

BUILD_DIR=../build SRC_DIR=../src

# Copy all app filescopy-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

Page 15: Using Ansible as Makefiles to unite your developers

BUILD_DIR=../build

# Create symlink of local.xmlsymlink-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

Page 16: Using Ansible as Makefiles to unite your developers

BUILD_DIR=../buildSRC_DIR=../srcdeclare -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

Page 17: Using Ansible as Makefiles to unite your developers

BUILD_DIR=../buildSRC_DIR=../srcdeclare -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 filescopy-app:

cp -R $(SRC_DIR) $(BUILD_DIR)

# Create local.xml symlinksymlink-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

Page 18: Using Ansible as Makefiles to unite your developers

Questions ?

Page 19: Using Ansible as Makefiles to unite your developers

Thank you ;D

@thiagoalessio github.com/thiagoalessio