SlideShare a Scribd company logo
INTERACTIVE REMOTE DEBUGGING AND
DEVELOPMENT WITH TRAMP MODE
EMACSCONF 2019
Greetings EmacsConf!

My name is Matt Ray, welcome to my session on Interactive Remote Debugging and Development with TRAMP Mode
GREETINGS
MATT RAY
▸ emacs@mattray.dev
▸ mattray IRC|GitHub|Slack|Twitter
▸ SoftwareDefinedTalk.com
▸ MattRay.dev
First, I'd like to thank the organizers of EmacsConf for allowing me to present. 

My name is Matt Ray and I've been using Emacs for about 20 years and figured it would be fun to share some of the ways I use Emacs in my day to day role.

I've been a developer and had various roles over the years.

I'm currently based in Sydney Australia, you can tell by my accent. I moved here about 3 years ago.

I'm 'mattray' on Twitter and Slack and GitHub and I co-host a rambling podcast called Software Defined Talk.

I blog from time to time about random tech stuff at MattRay.dev
EMACS
SHELL MODE
▸ Major mode for shell buffers
▸ M-x shell
▸ Bash
▸ Heavily customised PS1
▸ https://github.com/mattray/home-directory/
▸ .bashrc
▸ .emacs.d/init.el
I've been using M-x shell mode for probably 20 years, it's always been one of the killer features for me within Emacs.

The ability to capture everything I do in an editable shell has proven invaluable time and time again and frequently been a great way to get get people interested in
Emacs.

I'm still using Bash, newer shells like Zsh haven't really caught my eye because I've always gotten what I needed out of Shell mode.

<demo screen>

Within my .bashrc I set a couple of configuration settings, including setting more and less to cat so there's no weird pagination issues within shell mode.

My editor and git_editor shell variables are set for any commands that need to spawn an editor, and I use the emacs server to manage all of my emacs sessions within a
single window.

Shell history settings are there to optimise what's tracked, and I frequently grep my .bash_history file for anything not in the current shell session.
DEMO
M-X SHELL DEMO
▸ Start emacs
▸ M-x shell
▸ C-x 1
▸ M-+ 3x
▸ Cd emacsconf
▸ C-x C-f hello.sh
▸ Bash hello.sh
EMACS
TRAMP MODE
▸ Transparent Remote Access, Multiple Protocols
▸ Remote file editing over multiple protocols
▸ C-x C-f /[method/user@remotehost]/filename
▸ /ssh:cubert:/etc/hosts
▸ Sudo support
▸ /ssh:cubert|sudo@cubert:/etc/hosts
▸ /ssh:cubert|sudo:omnibus@cubert:~/
DEMO
EMACS
▸ C-x C-f /ssh:hyperchicken:/etc/hosts
▸ /ssh:hyperchicken|sudo:hyperchicken:/etc/
▸ Show off Dir-ed +1
▸ Edit /etc/motd
▸ Open iterm, ssh to the box to show off the MOTD
▸ Open up the hello.sh, write it remotely
BeagleBone black ARM box

I can open files on the remote system

I can sudo in and edit them as root

I can use DirEd to wander through the filesystem, poking around

I can also open a file locally, then write it to the remote system

I'll do that with my 'hello.sh'
EMACS
TRAMP MODE REMOTE SHELL
▸ C-u M-x shell
▸ Usually name the buffer after the host
▸ Default shell
▸ export PAGER=cat
Now editing files on a remote system is great and all, but I just showed off how I use Shell Mode.

I can use TRAMP to open a remote shell and run from there, just like on my local workstation.

I like to open a remote shell and name the buffer after the host, to make it easier to identify in my Buffer list
DEMO
EMACS
▸ C-u M-x shell
▸ Hostname
▸ /bin/bash
▸ Ls
▸ Ps
▸ whoami
▸ /tmp/hello.sh
Default shell

export PAGER=cat

I'm now running my shell over SSH on a remote server, editing files and copying content between buffers, pretty cool.
INFRASTRUCTURE
TEST KITCHEN
▸ Testing harness to execute infrastructure code in
isolation
▸ VM plugins for Vagrant, Docker, public and private
clouds
▸ Infrastructure as code with Chef, Puppet, Ansible
▸ Test frameworks like InSpec, ServerSpec, Bats
▸ https://kitchen.ci
Apache v2 licensed Free Software
INFRASTRUCTURE
VAGRANT
▸ Developer testing tool for desktop virtual machines
▸ Virtualbox, Docker and other providers
▸ Simple configuration with SSH access
▸ Standardized 'bento' images from Chef for basic
machines
▸ https://vagrantup.com
▸ C-x C-f /ssh:vagrant@127.0.0.1#2222:/
DEMO
EMACS
▸ Kitchen status
▸ Kitchen create
▸ Open kitchen.yml
▸ C-x C-f /ssh:vagrant@127.0.0.1#2222:/
▸ C-u M-x shell
▸ Whom
INFRASTRUCTURE
INSPEC
▸ Compliance as Code
▸ Ruby DSL
▸ 100s of Resources for auditing machines,
databases, APIs, cloud platforms, etc.
▸ Local or remote scanning
▸ https://inspec.io
Translate compliance into Code

Clearly express statements of policy

Move risk to build/test from runtime

Find issues early

Write code quickly

Run code anywhere

Inspect machines, data and APIs

100+ built-in resources
DEMO
EMACS
▸ Look at hello/controls/example.rb
▸ Kitchen verify
▸ Chmod +x hello.sh
▸ Kitchen verify
▸ Let's check on the command output, paste it in to our matcher
▸ It fails, why?
▸ Fix, kitchen verify
▸ Kitchen destroy
▸ Kitchen verify, now it's gone and broken
INFRASTRUCTURE
CHEF
▸ Infrastructure as Code
▸ Ruby DSL
▸ Resources for configuring servers in standardised
libraries for easy reuse
▸ Client/server scales to 100s of thousands of machines
▸ https://chef.io
Configuration Management, 

▪ Managesdeployment and on-going automation

▪ Definereusableresources

and infrastructure state as code

▪ Scale elegantly from one to tens of thousands of managed nodes across multiple complex environments

▪ Community, Certified Partner, and Chef supported content available for all common automation tasks
DEMO
EMACS
▸ Let's ensure that our file is always there
▸ Add the file resource
▸ Kitchen converge
▸ Kitchen verify
▸ Permissions again
▸ Mode '0755'
▸ Kitchen converge
▸ Kitchen verify
▸ Kitchen test
DEBUGGING
PRY
▸ Interactive Ruby debugger
▸ Built into Chef and InSpec
▸ Drop breakpoints into code
▸ ~/.emacs.d/ruby.el
DEMO
EMACS
▸ Drop debug into control
▸ Kitchen verify
▸ Exit-program, edit to bash resource
▸ Kitchen verify
▸ But it's hard-coded, so let's make it more dynamic
▸ Ls
▸ Content
▸ sys_info
▸ sys_info.methods
▸ sys_info.fqdn
▸ sys_info.short
▸ expected = "Hello EmacsConf 2019 from root on #{sys_info.short}"
▸ Whereami
▸ C 1
▸ Ls
▸ described_class
▸ described_class.methods
▸ described_class.result
▸ described_class.result.stdout
▸ Exit
▸ "".match?(expected)
▸ Exit-program
▸ Update example.rb
▸ Kitchen verify
▸ Kitchen test
Combining TRAMP with Shell Mode and local desktop testing with Kitchen make for a very fast feedback loop.

I can test through the shell and through Ruby without leaving Emacs, going back and forth between my Chef infrastructure code and my InSpec compliance code.

You might not be using these tools, but this pattern of rapid development feedback should be available to you no matter what you're working with.

If you're a system administrator, you don't need to have screen or tmux anymore.

If you're a developer you can deploy your applications into VM and test their behaviour in a clean room environment, using the same configurations as production
environments.

This was just a quick dive into Shell Mode, TRAMP, Chef, InSpec and Pry but hopefully you can take some of these ideas into your own Emacs setup and day to day
workflow.
THANKS!https://github.com/mattray/emacsconf2019
emacs@mattray.dev
This was just a quick dive into Shell Mode, TRAMP, Chef, InSpec and Pry but hopefully you can take some of these ideas into your own Emacs setup and day to day
workflow.

I've put this demo up on GitHub, there's a link to my emacs and bash configuration there as well.

Thanks again for allowing me to present, I'm available in IRC for any questions you may have or you can email me at emacs@mattray.dev

More Related Content

What's hot (19)

PDF
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
PDF
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
DOCX
Dockerfish-Tutorial
Brian Hood
 
PDF
Multi-provider Vagrant and Chef: AWS, VMware, and more
Chef Software, Inc.
 
PDF
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
PPTX
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
Sebastian Neubauer
 
KEY
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
PDF
Meetup C++ Floripa - Conan.io
Uilian Ries
 
PDF
DevOps(3) : Ansible - (MOSG)
Soshi Nemoto
 
KEY
Vagrant
Michael Peacock
 
PDF
Testing Your Automation Code (Docker Version)
Mischa Taylor
 
PPTX
DevOps hackathon Session 2: Basics of Chef
Antons Kranga
 
PDF
DevOps(4) : Ansible(2) - (MOSG)
Soshi Nemoto
 
PDF
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Puppet
 
KEY
Usando o Cloud
Fabio Kung
 
KEY
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
PDF
體驗 Hhvm
Chen Cheng-Wei
 
PDF
Conan a C/C++ Package Manager
Uilian Ries
 
PDF
Trust, but verify | Testing with Docker Containers
Nan Liu
 
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
Dockerfish-Tutorial
Brian Hood
 
Multi-provider Vagrant and Chef: AWS, VMware, and more
Chef Software, Inc.
 
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
6 Years of Docker: The Good, the Bad and Python Packaging at PyCon.DE&PyData ...
Sebastian Neubauer
 
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
Meetup C++ Floripa - Conan.io
Uilian Ries
 
DevOps(3) : Ansible - (MOSG)
Soshi Nemoto
 
Testing Your Automation Code (Docker Version)
Mischa Taylor
 
DevOps hackathon Session 2: Basics of Chef
Antons Kranga
 
DevOps(4) : Ansible(2) - (MOSG)
Soshi Nemoto
 
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Puppet
 
Usando o Cloud
Fabio Kung
 
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
體驗 Hhvm
Chen Cheng-Wei
 
Conan a C/C++ Package Manager
Uilian Ries
 
Trust, but verify | Testing with Docker Containers
Nan Liu
 

Similar to EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode (20)

PDF
Aucklug slides - desktop tips and tricks
Glen Ogilvie
 
PPTX
A Fabric/Puppet Build/Deploy System
adrian_nye
 
PDF
Testing Your Automation Code (Vagrant Version)
Mischa Taylor
 
PDF
Testing your-automation-code (vagrant version) v0.2
Sylvain Tissot
 
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
PDF
Chef basics - write infrastructure as code
stevaaa
 
PDF
Stop Being Lazy and Test Your Software
Laura Frank Tacho
 
PDF
The Modern Developer Toolbox
Pablo Godel
 
PPTX
What is Test Kitchen
Benoit Caron
 
PPTX
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
Karim Vaes
 
KEY
Capistrano, Puppet, and Chef
David Benjamin
 
PDF
Red Teaming macOS Environments with Hermes the Swift Messenger
Justin Bui
 
PDF
Be a happier developer with Docker: Tricks of the trade
Nicola Paolucci
 
PPTX
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
PDF
Be a Happier Developer with Docker: Tricks of the Trade
Docker, Inc.
 
PDF
Comment améliorer le quotidien des Développeurs PHP ?
AFUP_Limoges
 
PDF
Lean Drupal Repositories with Composer and Drush
Pantheon
 
PPTX
Docker Starter Pack
Saeed Hajizade
 
PDF
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Systems
 
PDF
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
Sébastien Morel
 
Aucklug slides - desktop tips and tricks
Glen Ogilvie
 
A Fabric/Puppet Build/Deploy System
adrian_nye
 
Testing Your Automation Code (Vagrant Version)
Mischa Taylor
 
Testing your-automation-code (vagrant version) v0.2
Sylvain Tissot
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Chef basics - write infrastructure as code
stevaaa
 
Stop Being Lazy and Test Your Software
Laura Frank Tacho
 
The Modern Developer Toolbox
Pablo Godel
 
What is Test Kitchen
Benoit Caron
 
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
Karim Vaes
 
Capistrano, Puppet, and Chef
David Benjamin
 
Red Teaming macOS Environments with Hermes the Swift Messenger
Justin Bui
 
Be a happier developer with Docker: Tricks of the trade
Nicola Paolucci
 
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
Be a Happier Developer with Docker: Tricks of the Trade
Docker, Inc.
 
Comment améliorer le quotidien des Développeurs PHP ?
AFUP_Limoges
 
Lean Drupal Repositories with Composer and Drush
Pantheon
 
Docker Starter Pack
Saeed Hajizade
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Systems
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
Sébastien Morel
 
Ad

More from Matt Ray (20)

PDF
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Matt Ray
 
PDF
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
Matt Ray
 
PDF
SCaLE 20X: Kubernetes Cloud Cost Monitoring with OpenCost & Optimization Stra...
Matt Ray
 
PDF
HashiTalks 2020 - Chef Tools & Terraform: Better Together
Matt Ray
 
PDF
Wellington DevOps: Bringing Your Applications into the Future with Habitat
Matt Ray
 
PDF
DevOps Days Singapore 2018 Ignite - Bringing Your Applications into the Futur...
Matt Ray
 
PDF
Cloud Expo Asia 20181010 - Bringing Your Applications into the Future with Ha...
Matt Ray
 
PDF
Compliance as Code Everywhere
Matt Ray
 
PDF
DevOpsDays Jakarta: State of DevOps 2018
Matt Ray
 
PDF
DevOps Talks Melbourne 2018: Whales, Cats and Kubernetes
Matt Ray
 
PDF
Infrastructure and Compliance Delight with Chef Automate
Matt Ray
 
PDF
Cooking Up Windows with Chef Automate
Matt Ray
 
PDF
DevOpsDays Singapore - Continuous Auditing with Compliance as Code
Matt Ray
 
PDF
DevOpsDays Singapore Habitat Ignite
Matt Ray
 
PDF
Chef Automate - Azure Sydney User Group
Matt Ray
 
PDF
Automating Compliance with InSpec - AWS North Sydney
Matt Ray
 
PDF
Automating Applications with Habitat - Sydney Cloud Native Meetup
Matt Ray
 
PDF
Automating AWS Compliance with InSpec
Matt Ray
 
PDF
Chef Automate - Infracoders Canberra August 8, 2017
Matt Ray
 
PDF
OpsWorks for Chef Automate - Auckland AWS
Matt Ray
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Matt Ray
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
Matt Ray
 
SCaLE 20X: Kubernetes Cloud Cost Monitoring with OpenCost & Optimization Stra...
Matt Ray
 
HashiTalks 2020 - Chef Tools & Terraform: Better Together
Matt Ray
 
Wellington DevOps: Bringing Your Applications into the Future with Habitat
Matt Ray
 
DevOps Days Singapore 2018 Ignite - Bringing Your Applications into the Futur...
Matt Ray
 
Cloud Expo Asia 20181010 - Bringing Your Applications into the Future with Ha...
Matt Ray
 
Compliance as Code Everywhere
Matt Ray
 
DevOpsDays Jakarta: State of DevOps 2018
Matt Ray
 
DevOps Talks Melbourne 2018: Whales, Cats and Kubernetes
Matt Ray
 
Infrastructure and Compliance Delight with Chef Automate
Matt Ray
 
Cooking Up Windows with Chef Automate
Matt Ray
 
DevOpsDays Singapore - Continuous Auditing with Compliance as Code
Matt Ray
 
DevOpsDays Singapore Habitat Ignite
Matt Ray
 
Chef Automate - Azure Sydney User Group
Matt Ray
 
Automating Compliance with InSpec - AWS North Sydney
Matt Ray
 
Automating Applications with Habitat - Sydney Cloud Native Meetup
Matt Ray
 
Automating AWS Compliance with InSpec
Matt Ray
 
Chef Automate - Infracoders Canberra August 8, 2017
Matt Ray
 
OpsWorks for Chef Automate - Auckland AWS
Matt Ray
 
Ad

Recently uploaded (20)

PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 

EmacsConf 2019: Interactive Remote Debugging and Development with TRAMP Mode

  • 1. INTERACTIVE REMOTE DEBUGGING AND DEVELOPMENT WITH TRAMP MODE EMACSCONF 2019 Greetings EmacsConf! My name is Matt Ray, welcome to my session on Interactive Remote Debugging and Development with TRAMP Mode
  • 2. GREETINGS MATT RAY ▸ [email protected] mattray IRC|GitHub|Slack|Twitter ▸ SoftwareDefinedTalk.com ▸ MattRay.dev First, I'd like to thank the organizers of EmacsConf for allowing me to present. My name is Matt Ray and I've been using Emacs for about 20 years and figured it would be fun to share some of the ways I use Emacs in my day to day role. I've been a developer and had various roles over the years. I'm currently based in Sydney Australia, you can tell by my accent. I moved here about 3 years ago. I'm 'mattray' on Twitter and Slack and GitHub and I co-host a rambling podcast called Software Defined Talk. I blog from time to time about random tech stuff at MattRay.dev
  • 3. EMACS SHELL MODE ▸ Major mode for shell buffers ▸ M-x shell ▸ Bash ▸ Heavily customised PS1 ▸ https://github.com/mattray/home-directory/ ▸ .bashrc ▸ .emacs.d/init.el I've been using M-x shell mode for probably 20 years, it's always been one of the killer features for me within Emacs. The ability to capture everything I do in an editable shell has proven invaluable time and time again and frequently been a great way to get get people interested in Emacs. I'm still using Bash, newer shells like Zsh haven't really caught my eye because I've always gotten what I needed out of Shell mode. <demo screen> Within my .bashrc I set a couple of configuration settings, including setting more and less to cat so there's no weird pagination issues within shell mode. My editor and git_editor shell variables are set for any commands that need to spawn an editor, and I use the emacs server to manage all of my emacs sessions within a single window. Shell history settings are there to optimise what's tracked, and I frequently grep my .bash_history file for anything not in the current shell session.
  • 4. DEMO M-X SHELL DEMO ▸ Start emacs ▸ M-x shell ▸ C-x 1 ▸ M-+ 3x ▸ Cd emacsconf ▸ C-x C-f hello.sh ▸ Bash hello.sh
  • 5. EMACS TRAMP MODE ▸ Transparent Remote Access, Multiple Protocols ▸ Remote file editing over multiple protocols ▸ C-x C-f /[method/user@remotehost]/filename ▸ /ssh:cubert:/etc/hosts ▸ Sudo support ▸ /ssh:cubert|sudo@cubert:/etc/hosts ▸ /ssh:cubert|sudo:omnibus@cubert:~/
  • 6. DEMO EMACS ▸ C-x C-f /ssh:hyperchicken:/etc/hosts ▸ /ssh:hyperchicken|sudo:hyperchicken:/etc/ ▸ Show off Dir-ed +1 ▸ Edit /etc/motd ▸ Open iterm, ssh to the box to show off the MOTD ▸ Open up the hello.sh, write it remotely BeagleBone black ARM box I can open files on the remote system I can sudo in and edit them as root I can use DirEd to wander through the filesystem, poking around I can also open a file locally, then write it to the remote system I'll do that with my 'hello.sh'
  • 7. EMACS TRAMP MODE REMOTE SHELL ▸ C-u M-x shell ▸ Usually name the buffer after the host ▸ Default shell ▸ export PAGER=cat Now editing files on a remote system is great and all, but I just showed off how I use Shell Mode. I can use TRAMP to open a remote shell and run from there, just like on my local workstation. I like to open a remote shell and name the buffer after the host, to make it easier to identify in my Buffer list
  • 8. DEMO EMACS ▸ C-u M-x shell ▸ Hostname ▸ /bin/bash ▸ Ls ▸ Ps ▸ whoami ▸ /tmp/hello.sh Default shell export PAGER=cat I'm now running my shell over SSH on a remote server, editing files and copying content between buffers, pretty cool.
  • 9. INFRASTRUCTURE TEST KITCHEN ▸ Testing harness to execute infrastructure code in isolation ▸ VM plugins for Vagrant, Docker, public and private clouds ▸ Infrastructure as code with Chef, Puppet, Ansible ▸ Test frameworks like InSpec, ServerSpec, Bats ▸ https://kitchen.ci Apache v2 licensed Free Software
  • 10. INFRASTRUCTURE VAGRANT ▸ Developer testing tool for desktop virtual machines ▸ Virtualbox, Docker and other providers ▸ Simple configuration with SSH access ▸ Standardized 'bento' images from Chef for basic machines ▸ https://vagrantup.com ▸ C-x C-f /ssh:[email protected]#2222:/
  • 11. DEMO EMACS ▸ Kitchen status ▸ Kitchen create ▸ Open kitchen.yml ▸ C-x C-f /ssh:[email protected]#2222:/ ▸ C-u M-x shell ▸ Whom
  • 12. INFRASTRUCTURE INSPEC ▸ Compliance as Code ▸ Ruby DSL ▸ 100s of Resources for auditing machines, databases, APIs, cloud platforms, etc. ▸ Local or remote scanning ▸ https://inspec.io Translate compliance into Code Clearly express statements of policy Move risk to build/test from runtime Find issues early Write code quickly Run code anywhere Inspect machines, data and APIs 100+ built-in resources
  • 13. DEMO EMACS ▸ Look at hello/controls/example.rb ▸ Kitchen verify ▸ Chmod +x hello.sh ▸ Kitchen verify ▸ Let's check on the command output, paste it in to our matcher ▸ It fails, why? ▸ Fix, kitchen verify ▸ Kitchen destroy ▸ Kitchen verify, now it's gone and broken
  • 14. INFRASTRUCTURE CHEF ▸ Infrastructure as Code ▸ Ruby DSL ▸ Resources for configuring servers in standardised libraries for easy reuse ▸ Client/server scales to 100s of thousands of machines ▸ https://chef.io Configuration Management, ▪ Managesdeployment and on-going automation ▪ Definereusableresources and infrastructure state as code ▪ Scale elegantly from one to tens of thousands of managed nodes across multiple complex environments ▪ Community, Certified Partner, and Chef supported content available for all common automation tasks
  • 15. DEMO EMACS ▸ Let's ensure that our file is always there ▸ Add the file resource ▸ Kitchen converge ▸ Kitchen verify ▸ Permissions again ▸ Mode '0755' ▸ Kitchen converge ▸ Kitchen verify ▸ Kitchen test
  • 16. DEBUGGING PRY ▸ Interactive Ruby debugger ▸ Built into Chef and InSpec ▸ Drop breakpoints into code ▸ ~/.emacs.d/ruby.el
  • 17. DEMO EMACS ▸ Drop debug into control ▸ Kitchen verify ▸ Exit-program, edit to bash resource ▸ Kitchen verify ▸ But it's hard-coded, so let's make it more dynamic ▸ Ls ▸ Content ▸ sys_info ▸ sys_info.methods ▸ sys_info.fqdn ▸ sys_info.short ▸ expected = "Hello EmacsConf 2019 from root on #{sys_info.short}" ▸ Whereami ▸ C 1 ▸ Ls ▸ described_class ▸ described_class.methods ▸ described_class.result ▸ described_class.result.stdout ▸ Exit ▸ "".match?(expected) ▸ Exit-program ▸ Update example.rb ▸ Kitchen verify ▸ Kitchen test Combining TRAMP with Shell Mode and local desktop testing with Kitchen make for a very fast feedback loop. I can test through the shell and through Ruby without leaving Emacs, going back and forth between my Chef infrastructure code and my InSpec compliance code. You might not be using these tools, but this pattern of rapid development feedback should be available to you no matter what you're working with. If you're a system administrator, you don't need to have screen or tmux anymore. If you're a developer you can deploy your applications into VM and test their behaviour in a clean room environment, using the same configurations as production environments. This was just a quick dive into Shell Mode, TRAMP, Chef, InSpec and Pry but hopefully you can take some of these ideas into your own Emacs setup and day to day workflow.
  • 18. THANKS!https://github.com/mattray/emacsconf2019 [email protected] This was just a quick dive into Shell Mode, TRAMP, Chef, InSpec and Pry but hopefully you can take some of these ideas into your own Emacs setup and day to day workflow. I've put this demo up on GitHub, there's a link to my emacs and bash configuration there as well. Thanks again for allowing me to present, I'm available in IRC for any questions you may have or you can email me at [email protected]