refactor: move into src

This commit is contained in:
Oliver Davies 2023-10-18 00:11:16 +02:00
parent 675e89e9d1
commit 51c5f5759d
404 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,4 @@
Building static websites with Sculpin
#####################################
https://www.oliverdavies.uk/talks/building-static-websites-sculpin

View file

@ -0,0 +1,5 @@
---
name: My talk
menu_links:
- { title: Home, href: / }
- { title: About, href: /about }

View file

@ -0,0 +1,6 @@
---
layout: default
title: Hello!
---
Hello, World!

View file

@ -0,0 +1,8 @@
- Adding a new page (`/talks`)
- Adding a new menu link
- Adding a new content type (talks)
- Add a new talk
- Show how to use page-level variables, adding events to a talk
- Adding the talks page to the menu
- Active menu link styling?
- Generating a production version of the site

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View file

@ -0,0 +1,129 @@
pageSetup:
firstTemplate: coverPage
height: 18cm
margin-bottom: 0cm
margin-gutter: 0cm
margin-left: 0cm
margin-right: 0cm
margin-top: 0cm
size: null
spacing-footer: 2mm
spacing-header: 2mm
width: 32cm
pageTemplates:
coverPage:
# background: images/title.png
frames: []
[12%, 10%, 76%, 75%]
showFooter: false
showHeader: false
titlePage:
alignment: TA_CENTER
frames: []
[8%, 8%, 85%, 65%]
showFooter: true
showHeader: false
standardPage:
frames: []
[3%, 3%, 92%, 92%]
showFooter: true
showHeader: false
imagePage:
alignment: TA_CENTER
frames: []
[12%, 10%, 76%, 80%]
showFooter: true
showHeader: false
outputPage:
frames: []
[8%, 10%, 82%, 65%]
showFooter: false
showHeader: false
linkColor: #24608a
fontsAlias:
stdMono: Inconsolata-Regular
stdMonoBold: Inconsolata-Regular
stdMonoBoldItalic: Inconsolata-Regular
stdMonoItalic: Inconsolata-Regular
styles:
normal:
fontSize: 24
leading: 32
textColor: #383745
bodytext:
alignment: TA_LEFT
heading:
fontSize: 20
spaceAfter: 16
textColor: #24608a
title:
fontSize: 300%
parent: heading
bullet-list:
commands: []
[LEFTPADDING, [0, 0], [1, -1], 10]
[RIGHTPADDING, [0, 0], [1, -1], 0]
[VALIGN, [0, 0], [-1, -1], TOP]
colWidths: ["20", null]
textColor: #aaaaaa
bullet-list-item:
spaceBefore: 14
spaceAfter: 0
titleslideinfo:
alignment: TA_CENTER
fontSize: 140%
parent: normal
footer:
alignment: TA_RIGHT
fontName: stdMono
fontSize: 20
textColor: #24608a
rightIndent: 16
spaceBefore: 0
literal:
backColor: white
fontName: stdMono
code:
backColor: white
borderWidth: 0
fontSize: 20
leading: 24
parent: literal
spaceBefore: 4
blockquote:
parent: normal
fontName: stdItalic
leading: 36
attribution:
parent: normal
textColor: #66666
centred:
alignment: TA_CENTER
parent: normal
centredtitle:
alignment: TA_CENTER
fontName: stdBold
fontSize: 48
leading: 64
parent: heading

View file

@ -0,0 +1,308 @@
.. footer:: @opdavies
Building static websites with Sculpin
#####################################
|
.. class:: titleslideinfo
Oliver Davies (@opdavies)
.. page:: imagePage
.. image:: druplicon.png
:width: 10cm
.. page::
.. image:: sculpin.png
:width: 10cm
.. page:: standardPage
What is Sculpin?
================
* Static site generator
* CLI tool
* Built on Symfony's HttpKernel
* HTML + Markdown + Twig = Static site
What do I use it for?
=====================
* My personal website
* Some client websites
* HTML prototypes and testing
* Learning YAML and Twig (and some Symfony)
Installation
============
``composer require sculpin/sculpin``
|
``composer create-project sculpin/blog-skeleton my-blog``
|
``composer create-project opdavies/sculpin-skeleton my-site``
Using Sculpin
=============
* Configuration lives in ``app/config``
* Source files live in ``source``.
Generate a site
===============
* ``vendor/bin/sculpin generate``
* ``--server``
* ``--watch``
* ``--env``
source/index.md
===============
.. code-block:: markdown
:include: code/index.md.txt
output_dev/index.html
=====================
.. code-block:: html
<!DOCTYPE html>
<head>
</head>
<body>
<p>Hello, World!</p>
</body>
Configuration
=============
- Stored in ``app/config``
- ``sculpin_site.yml``
- ``sculpin_site_{env}.yml``
- Key-value pairs
.. code-block:: yaml
:include: code/configuration.txt
Using on pages
==============
.. code-block:: html
<!DOCTYPE html>
<head>
<title>{{ site.name }}</title>
</head>
YAML front matter
=================
.. code-block:: yaml
---
layout: post
title: New blog post
draft: yes
---
# My new blog post
More front matter
=================
.. code-block:: yaml
---
layout: post
title: New blog post
draft: yes
tags:
- drupal
- php
- sculpin
---
# My new blog post
Even more front matter
======================
.. code-block:: yaml
---
layout: post
title: New blog post
draft: yes
tags:
- drupal
- php
- sculpin
tweets: yes
foo: bar
---
# My new blog post
Using on pages
==============
.. code-block:: twig
---
...
testimonials:
- { name: ..., role: ..., text: ..., url: ... }
- { name: ..., role: ..., text: ..., url: ... }
- { name: ..., role: ..., text: ..., url: ... }
---
{% for testimonial in page.testimonials %}
<h2>{{ testimonial.name }} - {{ testimonial.role }}</h2>
<p>{{ testimonial.text }}</p>
{% endfor %}
Layouts
=======
.. code-block:: twig
{# source/_layouts/app.html.twig #}
<!DOCTYPE html>
<html lang="{{ site.locale|default('en') }}">
<head>
<title>{{ site.name|default('Sculpin Skeleton') }}</title>
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>
Layouts
=======
.. code-block:: twig
{# source/_layouts/default.html.twig #}
{% extends 'app' %}
{% block body %}
{% block content %}{% endblock %}
{% endblock %}
Includes
========
.. code-block:: twig
{% include 'about-author' with {
avatar: site.avatar,
work: site.work,
} only %}
{% for link in links %}
{% include 'menu-link' with { link } only %}
{% endfor %}
Content types
=============
.. code-block:: yaml
# app/config/sculpin_kernel.yml
sculpin_content_types:
projects:
permalink: projects/:slug_title/
Accessing custom content types
==============================
.. code-block:: yaml
---
title: My Projects
layout: default
use:
- projects
---
{% for project in data.projects %}
<h2>{{ project.title }}</h2>
{% endfor %}
.. page:: titlePage
.. class:: centredtitle
Demo
.. page:: standardPage
Extending Sculpin
=================
.. code-block:: yaml
# app/config/sculpin_kernel.yml
...
services:
App\TwigExtension\TalkExtension:
tags:
- { name: twig.extension }
.. page:: imagePage
.. image:: images/packagist.png
:width: 22cm
.. page:: standardPage
.. code-block:: php
:startinline: true
// app/SculpinKernel.php
use Opdavies\Sculpin\Bundle\TwigMarkdownBundle\SculpinTwigMarkdownBundle;
use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel;
final class SculpinKernel extends AbstractKernel
{
protected function getAdditionalSculpinBundles(): array
{
return [
SculpinTwigMarkdownBundle::class,
];
}
}
Thanks!
=======
References:
* https://sculpin.io
* https://github.com/opdavies/sculpin-talk-demo
* https://github.com/opdavies/oliverdavies.uk
* https://github.com/opdavies/docker-image-sculpin-serve
|
Me:
* https://www.oliverdavies.uk

View file

@ -0,0 +1,4 @@
Working with Workspace
######################
https://www.oliverdavies.uk/talks/working-with-workspace

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

View file

@ -0,0 +1,141 @@
pageSetup:
firstTemplate: coverPage
height: 18cm
margin-bottom: 0cm
margin-gutter: 0cm
margin-left: 0cm
margin-right: 0cm
margin-top: 0cm
size: null
spacing-footer: 2mm
spacing-header: 2mm
width: 32cm
pageTemplates:
coverPage:
frames: []
[12%, 10%, 76%, 75%]
showFooter: false
showHeader: false
background: ../images/bg-dark.png
titlePage:
alignment: TA_CENTER
frames: []
[8%, 8%, 85%, 65%]
showFooter: true
showHeader: false
background: ../images/bg-dark.png
standardPage:
frames: []
[3%, 3%, 92%, 92%]
showFooter: true
showHeader: false
background: ../images/bg-dark.png
imagePage:
alignment: TA_CENTER
frames: []
[12%, 10%, 76%, 80%]
showFooter: true
showHeader: false
background: ../images/bg-dark.png
outputPage:
frames: []
[8%, 10%, 82%, 65%]
showFooter: false
showHeader: false
background: ../images/bg-dark.png
linkColor: #60a5fa
fontsAlias:
stdMono: Inconsolata-Regular
stdMonoBold: Inconsolata-Regular
stdMonoItalic: Inconsolata-Regular
styles:
normal:
fontSize: 24
leading: 32
textColor: #ffffff
bodytext:
alignment: TA_LEFT
heading:
fontSize: 20
spaceAfter: 16
textColor: #60a5fa
heading1:
parent: heading
alignment: TA_LEFT
title:
fontSize: 300%
parent: heading
bullet-list:
commands: []
[LEFTPADDING, [0, 0], [1, -1], 10]
[RIGHTPADDING, [0, 0], [1, -1], 0]
[VALIGN, [0, 0], [-1, -1], TOP]
colWidths: ["20", null]
textColor: #aaaaaa
bullet-list-item:
spaceBefore: 14
spaceAfter: 0
titleslideinfo:
alignment: TA_CENTER
fontSize: 140%
parent: normal
footer:
alignment: TA_RIGHT
fontName: stdMono
fontSize: 20
textColor: #60a5fa
rightIndent: 16
spaceBefore: 0
literal:
backColor: white
fontName: stdMono
code:
backColor: white
borderWidth: 0
fontSize: 19
leading: 22
parent: literal
spaceBefore: 4
blockquote:
parent: normal
fontName: stdItalic
leading: 36
attribution:
parent: normal
textColor: #66666
centred:
alignment: TA_CENTER
parent: normal
centredtitle:
alignment: TA_CENTER
fontName: stdBold
fontSize: 48
leading: 64
parent: heading
small:
fontSize: 90%
parent: normal

View file

@ -0,0 +1,136 @@
pageSetup:
firstTemplate: coverPage
height: 18cm
margin-bottom: 0cm
margin-gutter: 0cm
margin-left: 0cm
margin-right: 0cm
margin-top: 0cm
size: null
spacing-footer: 2mm
spacing-header: 2mm
width: 32cm
pageTemplates:
coverPage:
frames: []
[12%, 10%, 76%, 75%]
showFooter: false
showHeader: false
titlePage:
alignment: TA_CENTER
frames: []
[8%, 8%, 85%, 65%]
showFooter: true
showHeader: false
standardPage:
frames: []
[3%, 3%, 92%, 92%]
showFooter: true
showHeader: false
imagePage:
alignment: TA_CENTER
frames: []
[12%, 10%, 76%, 80%]
showFooter: true
showHeader: false
outputPage:
frames: []
[8%, 10%, 82%, 65%]
showFooter: false
showHeader: false
linkColor: #0045aa
fontsAlias:
stdMono: Inconsolata-Regular
stdMonoBold: Inconsolata-Regular
stdMonoItalic: Inconsolata-Regular
styles:
normal:
fontSize: 24
leading: 32
textColor: #383745
bodytext:
alignment: TA_LEFT
heading:
fontSize: 20
spaceAfter: 16
textColor: #0045aa
heading1:
parent: heading
alignment: TA_LEFT
title:
fontSize: 300%
parent: heading
bullet-list:
commands: []
[LEFTPADDING, [0, 0], [1, -1], 10]
[RIGHTPADDING, [0, 0], [1, -1], 0]
[VALIGN, [0, 0], [-1, -1], TOP]
colWidths: ["20", null]
textColor: #aaaaaa
bullet-list-item:
spaceBefore: 14
spaceAfter: 0
titleslideinfo:
alignment: TA_CENTER
fontSize: 140%
parent: normal
footer:
alignment: TA_RIGHT
fontName: stdMono
fontSize: 20
textColor: #0045aa
rightIndent: 16
spaceBefore: 0
literal:
backColor: white
fontName: stdMono
code:
backColor: white
borderWidth: 0
fontSize: 19
leading: 22
parent: literal
spaceBefore: 4
blockquote:
parent: normal
fontName: stdItalic
leading: 36
attribution:
parent: normal
textColor: #66666
centred:
alignment: TA_CENTER
parent: normal
centredtitle:
alignment: TA_CENTER
fontName: stdBold
fontSize: 48
leading: 64
parent: heading
small:
fontSize: 90%
parent: normal

View file

@ -0,0 +1,46 @@
.. page:: standardPage
What is Ansible?
================
.. class:: text-lg
Ansible is an open-source **software provisioning**, **configuration management**, and **application-deployment** tool.
|
https://en.wikipedia.org/wiki/Ansible_(software)
.. page::
What is Ansible?
================
- CLI tool
- Configured with YAML
- Agentless, connects via SSH
- Jinja2 for templating
- Executes ad-hoc remote commands
- Installs software packages
- Performs deployment steps
- Batteries included
.. raw:: pdf
TextAnnotation "- Written in Python but configured with Yaml."
TextAnnotation "Drupal, Symfony and a lot of other projects use YAML."
TextAnnotation "Nothing needed on the server, other than Python."
TextAnnotation "First-party modules (SSH keys, file and directory management, package repositories, stopping/starting/restarting services, DO/Linode/AWS integration)."
.. page::
Why Ansible?
============
- Familiar syntax (Drupal 8, Symfony, Sculpin)
- Easily readable
- No server dependencies
- Easy to add to an existing project
- Includes relevant modules (Git, Composer)
- Idempotency, resulting in cleaner scripts

View file

@ -0,0 +1,144 @@
.. page:: titlePage
.. class:: centredtitle
Hosts / Inventories
.. page:: standardPage
hosts.ini
=========
.. code:: ini
[webservers]
192.168.33.10
[webservers:vars]
ansible_ssh_port=22
ansible_ssh_user=opdavies
.. raw:: pdf
TextAnnotation "Vagrant IP address."
TextAnnotation "Supports wildcards and ranges"
hosts.yml
=========
.. code-block:: yaml
---
all:
children:
webservers:
hosts:
192.168.33.10:
vars:
ansible_ssh_port: 22
ansible_ssh_user: opdavies
.. raw:: pdf
TextAnnotation "My prefered format."
TextAnnotation "More consistency across the project, easier to copy variables from other places such as playbooks."
.. page:: titlePage
.. class:: centredtitle
Ad-hoc Commands
.. page::
.. class:: centredtitle
``ansible all -i hosts.yml
-m ping``
.. raw:: pdf
TextAnnotation "Single ad-hoc command."
TextAnnotation "-i = inventory"
TextAnnotation "-m = module"
.. page:: standardPage
.. code:: json
webservers | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
.. page:: titlePage
.. class:: centredtitle
``ansible all -i hosts.yml
-m command
-a "git pull --chdir=/app"``
.. raw:: pdf
TextAnnotation "Update a codebase using "git pull""
TextAnnotation "-a = (additional) arguments"
TextAnnotation "--chdir = change directory"
.. page::
.. class:: centredtitle
``ansible all -i hosts.yml
-m git
-a "repo=https://github.com
/opdavies/dransible
--chdir=/app"``
.. raw:: pdf
TextAnnotation "Same example, but using the core "Git" module"
.. page:: titlePage
.. class:: centredtitle
Playbooks
.. page:: standardPage
.. code-block:: yaml
---
- hosts: webservers
vars:
git_repo: https://github.com/opdavies/dransible
project_root_dir: /app
tasks:
- name: Update the code
git:
repo: '{{ git_repo }}'
dest: '{{ project_root_dir }}'
.. raw:: pdf
TextAnnotation "YAML file"
TextAnnotation "Collection of multiple tasks"
TextAnnotation "Can add and use variables"
.. page:: titlePage
.. class:: centredtitle
``ansible-playbook main.yml
-i hosts.yml``
.. raw:: pdf
TextAnnotation "How do we run a playbook?"
TextAnnotation "Use the ansible-playbook command and specify the name of the playbook."

View file

@ -0,0 +1,106 @@
.. page:: titlePage
.. class:: centredtitle
Keeping secrets with Ansible Vault
.. page:: standardPage
.. code-block:: yaml
---
vars:
mysql_databases:
- name: main
mysql_users:
- name: user
password: secret
priv: main.*:ALL
.. page::
.. code-block:: yaml
# provision_vault.yml
---
vault_database_name: main
vault_database_user: user
vault_database_password: secret
.. page:: titlePage
.. class:: centredtitle
``ansible-vault encrypt
provision_vault.yml``
.. class:: centredtitle
``New Vault password:
Confirm New Vault password:
Encryption successful``
.. page:: standardPage
.. code-block::
$ANSIBLE_VAULT;1.1;AES256
63656632326165643137646334343537396533656565313032363262623962393861666438393539
6366336638316133373061306332303761383565343035330a373637373830356430353630356161
32313831663039343733343539636365386333303862363635323138346137666166356639323338
3264636538356634390a343766353661386666376362376439386630363664616166643364366335
62373530393933373830306338386539626565313364643133666131613138383431353638636334
39376437633462373934313236363662633832643138386433646230313465383337373031373137
61353963623364393134386335373731356337366464633531656435383161656435313530363234
37373865393839616534353165656463313961333532363537383263343364646534333032336337
3235
.. page::
.. code-block:: yaml
# provision_vars.yml
---
database_name: '{{ vault_database_name }}'
database_user: '{{ vault_database_user }}'
database_password: '{{ vault_database_password }}'
.. page::
.. code-block:: yaml
# provision.yml
---
vars_files:
- vars/provision_vault.yml
- vars/provision_vars.yml
vars:
mysql_databases:
- '{{ database_name }}'
mysql_users:
- name: '{{ database_user }}'
password: '{{ database_password }}'
priv: '{{ database_name }}.*:ALL'
.. page:: titlePage
.. class:: centredtitle
``ansible-playbook deploy.yml
-i hosts.yml
--ask-vault-pass``
.. page::
.. class:: centredtitle
``ansible-playbook deploy.yml
-i hosts.yml
--vault-password-file secret.txt``

View file

@ -0,0 +1,243 @@
.. page:: titlePage
.. class:: centredtitle
Better deployments with Ansistrano
.. page:: standardPage
.. image:: images/ansistrano.png
:width: 24cm
.. page::
Features
========
- Multiple release directories
- Shared paths and files
- Customisable
- Multiple deployment strategies
- Multi-stage environments
- Prune old releases
- Rollbacks
.. page::
.. code-block:: yaml
# requirements.yml
---
- src: ansistrano.deploy
- src: ansistrano.rollback
.. raw:: pdf
TextAnnotation "to install Ansistrano, add the additional roles to the requirements.yml file"
.. page::
.. code-block:: yaml
# deploy.yml
---
- hosts: all
roles:
- ansistrano.deploy
.. raw:: pdf
TextAnnotation "add to roles within the playbook"
.. page::
.. code-block:: yaml
# deploy.yml
---
vars:
project_deploy_dir: /app
ansistrano_deploy_to: '{{ project_deploy_dir }}'
ansistrano_deploy_via: git
ansistrano_git_branch: master
ansistrano_git_repo: 'git@github.com:opdavies/dransible'
.. page::
.. code-block::
PLAY [webservers] ******************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************
ok: [webservers]
TASK [ansistrano.deploy : include_tasks] *******************************************************************************
TASK [ansistrano.deploy : include_tasks] *******************************************************************************
included: /Users/opdavies/.ansible/roles/ansistrano.deploy/tasks/setup.yml for webservers
TASK [ansistrano.deploy : ANSISTRANO | Ensure deployment base path exists] *********************************************
ok: [webservers]
TASK [ansistrano.deploy : ANSISTRANO | Ensure releases folder exists] **************************************************
ok: [webservers]
TASK [ansistrano.deploy : ANSISTRANO | Ensure shared elements folder exists] *******************************************
ok: [webservers]
TASK [ansistrano.deploy : ANSISTRANO | Ensure shared paths exists] *****************************************************
ok: [webservers] => (item=web/sites/default/files)
.. page::
.. code-block::
TASK [ansistrano.deploy : Update file permissions] *********************************************************************
changed: [webservers]
TASK [ansistrano.deploy : include_tasks] *******************************************************************************
TASK [ansistrano.deploy : include_tasks] *******************************************************************************
included: /Users/opdavies/.ansible/roles/ansistrano.deploy/tasks/cleanup.yml for webservers
TASK [ansistrano.deploy : ANSISTRANO | Clean up releases] **************************************************************
changed: [webservers]
TASK [ansistrano.deploy : include_tasks] *******************************************************************************
TASK [ansistrano.deploy : include_tasks] *******************************************************************************
included: /Users/opdavies/.ansible/roles/ansistrano.deploy/tasks/anon-stats.yml for webservers
TASK [ansistrano.deploy : ANSISTRANO | Send anonymous stats] ***********************************************************
skipping: [webservers]
PLAY RECAP *************************************************************************************************************
webservers : ok=33 changed=14 unreachable=0 failed=0 skipped=7 rescued=0 ignored=0
.. page::
.. code-block::
vagrant@dransible:/app$ ls -l
total 8
lrwxrwxrwx 1 26 Jul 19 00:15 current -> ./releases/20190719001241Z
drwxr-xr-x 5 4096 Jul 22 20:30 releases
drwxr-xr-x 4 4096 Jul 19 00:00 shared
.. page::
.. code-block::
vagrant@dransible:/app/releases$ ls -l
total 20
drwxr-xr-x 5 4096 Jul 22 20:30 .
drwxr-xr-x 4 4096 Jul 19 00:15 ..
drwxr-xr-x 10 4096 Jul 19 00:02 20190719000013Z
drwxr-xr-x 10 4096 Jul 19 00:14 20190719001241Z
drwxr-xr-x 9 4096 Jul 22 20:30 20190722203038Z
.. page::
.. code-block:: yaml
# rollback.yml
---
- hosts: all
roles:
- ansistrano.rollback
vars:
ansistrano_deploy_to: '{{ project_deploy_dir }}'
.. page:: titlePage
.. class:: centredtitle
``ansible-playbook rollback.yml
-i hosts.yml``
.. page::
.. class:: centredtitle
Customising Ansistrano:
Build Hooks
.. page:: imagePage
.. image:: images/ansistrano-flow.png
:width: 18cm
.. raw:: pdf
TextAnnotation "Each step has a 'before' and 'after' step Ansistrano allows us to add more things by providing a path to a playbook and adding additional steps."
.. page:: standardPage
.. code-block:: yaml
# deploy.yml
---
vars:
ansistrano_after_symlink_shared_tasks_file: >
'{{ playbook_dir }}/deploy/after-symlink-shared.yml'
ansistrano_after_symlink_tasks_file: >
'{{ playbook_dir }}/deploy/after-symlink.yml'
ansistrano_after_update_code_tasks_file: >
'{{ playbook_dir }}/deploy/after-update-code.yml'
release_web_path: '{{ ansistrano_release_path.stdout }}/web'
release_drush_path: '{{ ansistrano_release_path.stdout }}/bin/drush'
.. page::
.. code-block:: yaml
# deploy/after-update-code.yml
---
- name: Install Composer dependencies
composer:
command: install
working_dir: '{{ ansistrano_release_path.stdout }}'
.. page::
.. code-block:: yaml
# deploy/after-symlink-shared.yml
---
- name: Run database updates
command: >
{{ release_drush_path }}
--root {{ release_web_path }}
updatedb
.. page::
.. code-block:: yaml
# deploy/after-symlink.yml
---
- name: Rebuild Drupal cache
command: >
{{ release_drush_path }}
--root {{ release_web_path }}
cache-rebuild

View file

@ -0,0 +1,61 @@
.. page:: titlePage
.. class:: centredtitle
Basic deployment
.. page:: standardPage
.. class:: small
.. code-block:: yaml
# deploy.yml
---
tasks:
- name: Creating project directory
file:
path: /app
state: directory
- name: Uploading application
synchronize:
src: '{{ playbook_dir }}/../'
dest: /app
- name: Installing Composer dependencies
composer:
command: install
working_dir: /app
.. raw:: pdf
TextAnnotation "Using file module to create the directory"
TextAnnotation "Using synchronize module/rsync to upload the files"
TextAnnotation "Using Composer module to install dependencies. There are other possible values."
.. page:: titlePage
.. class:: centredtitle
``ansible-playbook deploy.yml
-i hosts.yml``
.. page:: standardPage
.. image:: images/after-deploy-1.png
:width: 24cm
.. page:: standardPage
Disadvantages
=============
- Sensitive data stored in plain text
- Single point of failure
- No ability to roll back

View file

@ -0,0 +1,187 @@
.. page:: titlePage
.. class:: centredtitle
Configuring a LAMP stack
.. page:: standardPage
requirements.yml
================
.. code-block:: yaml
---
- src: geerlingguy.apache
- src: geerlingguy.composer
- src: geerlingguy.mysql
- src: geerlingguy.php
- src: geerlingguy.php-mysql
.. raw:: pdf
TextAnnotation "Requirements file for Ansible roles"
TextAnnotation "Typically requirements.yml"
TextAnnotation "Pulled from Ansible Galaxy"
TextAnnotation "Equivilent to composer.json/Packagist in PHP"
.. page:: titlePage
.. class:: centredtitle
``ansible-galaxy install
-r requirements.yml``
.. page:: standardPage
.. code-block:: yaml
# playbook.yml
---
- hosts: webservers
roles:
- geerlingguy.apache
- geerlingguy.mysql
- geerlingguy.php
- geerlingguy.php-mysql
- geerlingguy.composer
.. raw:: pdf
TextAnnotation "How do we use them?"
TextAnnotation "Add them to the playbook under 'roles'."
TextAnnotation "Ordering matters here!"
TextAnnotation "If these were ordered alphabetically then Composer install would fail because it would run before PHP is installed."
.. page::
.. code-block:: yaml
# playbook.yml
---
vars:
apache_vhosts:
- servername: dransible
documentroot: /app/web
.. raw:: pdf
TextAnnotation "configuring the Apache role to install virtual hosts."
.. page::
.. code-block:: yaml
# playbook.yml
---
vars:
php_version: 7.4
php_packages_extra:
- libapache2-mod-php{{ php_version }}
- libpcre3-dev
.. raw:: pdf
TextAnnotation "configuring PHP."
.. page::
.. code-block:: yaml
# playbook.yml
---
vars:
mysql_databases:
- name: main
mysql_users:
- name: user
password: secret
priv: main.*:ALL
.. raw:: pdf
TextAnnotation "configuring MySQL databases and users."
.. page:: titlePage
.. class:: centredtitle
``ansible-playbook provision.yml
-i hosts.yml``
.. page:: standardPage
.. code-block::
PLAY [Provision the webserver machines] ********************************************************************************
TASK [Gathering Facts] *************************************************************************************************
ok: [webservers]
TASK [geerlingguy.apache : Include OS-specific variables.] *************************************************************
ok: [webservers]
TASK [geerlingguy.apache : Include variables for Amazon Linux.]
skipping: [webservers]
TASK [geerlingguy.apache : Define apache_packages.] ********************************************************************
ok: [webservers]
TASK [geerlingguy.apache : include_tasks] ******************************************************************************
included: /Users/opdavies/.ansible/roles/geerlingguy.apache/tasks/setup-Debian.yml for webservers
TASK [geerlingguy.apache : Update apt cache.] **************************************************************************
changed: [webservers]
.. page::
.. code-block::
TASK [geerlingguy.composer : Ensure composer directory exists.] ********************************************************
ok: [webservers]
TASK [geerlingguy.composer : include_tasks] ****************************************************************************
skipping: [webservers]
TASK [geerlingguy.composer : include_tasks] ****************************************************************************
skipping: [webservers]
RUNNING HANDLER [geerlingguy.apache : restart apache] ******************************************************************
changed: [webservers]
RUNNING HANDLER [geerlingguy.mysql : restart mysql] ********************************************************************
changed: [webservers]
RUNNING HANDLER [geerlingguy.php : restart webserver] ******************************************************************
changed: [webservers]
RUNNING HANDLER [geerlingguy.php : restart php-fpm] ********************************************************************
skipping: [webservers]
PLAY RECAP *************************************************************************************************************
webservers : ok=111 changed=32 unreachable=0 failed=0 skipped=78 rescued=0 ignored=0
.. page::
.. image:: images/after-provision-1.png
:width: 24cm
.. raw:: pdf
TextAnnotation "IP address of server, Apache is installed and running."
.. page::
.. image:: images/after-provision-2.png
:width: 24cm
.. raw:: pdf
TextAnnotation "No application code on the server yet."

View file

@ -0,0 +1,80 @@
.. page:: titlePage
.. class:: centredtitle
Generating settings files per deployment
.. page:: standardPage
.. code-block:: yaml
# deploy_vars.yml
---
drupal_settings:
- drupal_root: /app/web
sites:
- name: default
settings:
databases:
default:
default:
driver: mysql
host: localhost
database: '{{ database_name }}'
username: '{{ database_user }}'
password: '{{ database_password }}'
hash_salt: '{{ hash_salt }}'
config_directories:
sync: ../config/sync
.. page::
.. code-block:: jinja
{# templates/settings.php.j2 #}
{% for key, values in item.1.settings.databases.items() %}
{% for target, values in values.items() %}
$databases['{{ key }}']['{{ target }}'] = array(
'driver' => '{{ values.driver|default('mysql') }}',
'host' => '{{ values.host|default('localhost') }}',
'database' => '{{ values.database }}',
'username' => '{{ values.username }}',
'password' => '{{ values.password }}',
);
{% endfor %}
{% endfor %}
{% if item.1.settings.base_url is defined %}
$base_url = '{{ item.1.settings.base_url }}';
{% endif %}
.. page::
.. code-block:: yaml
# tasks/main.yml
---
- name: Ensure directory exists
file:
state: directory
path: '{{ item.0.drupal_root }}/sites/{{ item.1.name|default("default") }}'
with_subelements:
- '{{ drupal_settings }}'
- sites
no_log: true
- name: Create settings files
template:
src: settings.php.j2
dest:
'{{ item.0.drupal_root }}/sites/{{ item.1.name|default("default") }}/{{
item.1.filename|default("settings.php") }}'
with_subelements:
- '{{ drupal_settings }}'
- sites
no_log: true

View file

@ -0,0 +1,8 @@
.. page:: standardPage
Things we'll be looking at
==========================
- **Ansible** crash course
- Keeping secrets with **Ansible Vault**
- Deployments with **Ansistrano**

View file

@ -0,0 +1,89 @@
.. page:: titlePage
.. class:: centredtitle
Multiple environments development, test, production
.. page:: standardPage
.. code-block:: yaml
# vars.yml
---
vars:
mysql_databases:
- name: production
- name: staging
mysql_users:
- name: production
password: '{{ live_db_password }}'
priv: '{{ live_db_name }}.*:ALL'
- name: staging
password: '{{ staging_db_password }}'
priv: staging.*:ALL
.. page::
.. code-block:: yaml
# hosts.yml
---
production:
children:
hosts:
webservers:
ansible_ssh_host: 192.168.33.10
ansible_ssh_port: 22
project_deploy_path: /app
git_branch: production
drupal_hash_salt: '{{ vault_drupal_hash_salt }}'
drupal_install: false
drupal_settings:
# ...
.. page::
.. code-block:: yaml
# hosts.yml
---
staging:
children:
hosts:
webservers:
ansible_ssh_host: 192.168.33.10
ansible_ssh_port: 22
project_deploy_path: /app-staging
git_branch: staging
drupal_hash_salt: '{{ vault_drupal_hash_salt }}'
drupal_install: true
drupal_settings:
# ...
.. page:: titlePage
.. class:: centredtitle
``ansible-playbook deploy.yml
-i hosts.yml
--limit staging``
.. page::
.. class:: centredtitle
``ansible-playbook deploy.yml
-i hosts.yml
--limit production``

View file

@ -0,0 +1,52 @@
.. footer:: @opdavies
Deploying PHP with Ansible, Ansible Vault, and Ansistrano
#########################################################
|
.. class:: titleslideinfo
Oliver Davies, Inviqa
.. raw:: pdf
TextAnnotation "Full stack Developer and Systems Administrator"
TextAnnotation "Organiser of PHP South Wales"
.. page:: imagePage
.. image:: images/techs.png
:width: 14cm
.. include:: sections/building-a-lamp-stack.rst
.. include:: sections/basic-deployment.rst
.. include:: sections/ansible-vault.rst
.. include:: sections/ansistrano.rst
.. page:: titlePage
.. class:: centredtitle
Demo
.. include:: sections/generating-settings-files.rst
.. include:: sections/multiple-environments.rst
.. page:: standardPage
Thanks!
=======
References:
- https://oliverdavies.link/ansible-repos
- https://docs.ansible.com
- https://www.ansistrano.com
- https://symfonycasts.com/screencast/ansistrano
|
Me:
* https://www.oliverdavies.uk

View file

@ -0,0 +1,52 @@
.. footer:: @opdavies
Deploying PHP with Ansible, Ansible Vault, and Ansistrano
#########################################################
|
.. class:: titleslideinfo
Oliver Davies (@opdavies)
.. raw:: pdf
TextAnnotation "Full stack Developer and Systems Administrator"
TextAnnotation "Organiser of PHP South Wales"
.. page:: standardPage
.. include:: sections/intro.rst
.. include:: sections/about-ansible.rst
.. include:: sections/ansible-crash-course.rst
.. include:: sections/building-a-lamp-stack.rst
.. include:: sections/basic-deployment.rst
.. include:: sections/ansible-vault.rst
.. include:: sections/ansistrano.rst
.. page:: titlePage
.. class:: centredtitle
Demo
.. include:: sections/generating-settings-files.rst
.. include:: sections/multiple-environments.rst
.. page:: standardPage
Thanks!
=======
References:
- https://oliverdavies.link/ansible-repos
- https://docs.ansible.com
- https://www.ansistrano.com
- https://symfonycasts.com/screencast/ansistrano
|
Me:
* https://www.oliverdavies.uk

View file

@ -0,0 +1,4 @@
Upgrading to Drupal 9
#####################
https://www.oliverdavies.uk/talks/upgrading-your-site-drupal-9

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

View file

@ -0,0 +1,126 @@
pageSetup:
firstTemplate: coverPage
height: 18cm
margin-bottom: 0cm
margin-gutter: 0cm
margin-left: 0cm
margin-right: 0cm
margin-top: 0cm
size: null
spacing-footer: 2mm
spacing-header: 2mm
width: 32cm
pageTemplates:
coverPage:
frames: []
[12%, 10%, 76%, 75%]
showFooter: false
showHeader: false
titlePage:
alignment: TA_CENTER
frames: []
[8%, 8%, 85%, 60%]
showFooter: true
showHeader: false
standardPage:
frames: []
[3%, 3%, 94%, 92%]
showFooter: true
showHeader: false
imagePage:
alignment: TA_CENTER
frames: []
[12%, 10%, 76%, 80%]
showFooter: true
showHeader: false
linkColor: #24608a
fontsAlias:
stdMono: Inconsolata-Regular
stdMonoBold: Inconsolata-Regular
stdMonoItalic: Inconsolata-Regular
styles:
normal:
fontSize: 28
textColor: #383745
bodytext:
alignment: TA_LEFT
heading:
alignment: TA_CENTER
fontSize: 24
spaceAfter: 16
textColor: #24608a
heading1:
parent: heading
alignment: TA_LEFT
title:
fontSize: 250%
parent: heading
bullet-list:
commands: []
[LEFTPADDING, [0, 0], [1, -1], 10]
[RIGHTPADDING, [0, 0], [1, -1], 0]
[VALIGN, [0, 0], [-1, -1], TOP]
colWidths: ["20", null]
textColor: #aaaaaa
bullet-list-item:
spaceBefore: 14
spaceAfter: 0
titleslideinfo:
alignment: TA_CENTER
fontSize: 120%
parent: normal
footer:
alignment: TA_RIGHT
fontName: stdMono
fontSize: 18
textColor: #24608a
rightIndent: 16
spaceBefore: 0
literal:
backColor: white
fontName: stdMono
code:
backColor: white
borderWidth: 0
fontSize: 24
parent: literal
spaceBefore: 4
blockquote:
parent: normal
fontName: stdItalic
attribution:
parent: normal
textColor: #666666
smaller:
textColor: red
centredtitle:
alignment: TA_CENTER
fontName: stdBold
fontSize: 48
leading: 64
parent: heading
centred:
alignment: TA_CENTER
parent: normal

View file

@ -0,0 +1,488 @@
.. footer:: @opdavies
Upgrading to Drupal 9
#####################
|
.. class:: titleslideinfo
Oliver Davies, Inviqa
.. raw:: pdf
PageBreak imagePage
.. image:: images/10-years-tweet.png
:width: 22cm
.. raw:: pdf
TextAnnotation "Recently, I passed 10 years working full-time with Drupal and PHP (I'd been working with it for a few years prior to this too)."
TextAnnotation "Worked with Drupal 6, 7, 8 and 9."
TextAnnotation "Worked on a number of D6 to D7, and D8 to D9 upgrades"
PageBreak standardPage
The D7 release cycle
====================
* One long-running branch
* Minor versions for bug fixes (7.80, April 2021)
* No big, new features
* Long time for changes to get committed to core
.. raw:: pdf
TextAnnotation "Before we get into the D9 stuff."
TextAnnotation "D7 and earlier..."
The D8 release cycle
====================
* Semantic versioning for core
* Minor release (new features) every 6 months
* Patch release (bug fixes) every month
* Multiple supported versions of core (8.9, 9.0, 9.1)
.. raw:: pdf
TextAnnotation "Drupal 8 onwards..."
TextAnnotation "Minor release = new functionality"
TextAnnotation "Patch release = bug fixes"
TextAnnotation "Change from 'it will be ready when it's ready' (D7) to a fixed release cycle and schedule, and what makes it in time will be added."
TextAnnotation "8.9 is an LTS release"
.. raw:: pdf
PageBreak imagePage
.. image:: images/2019_minor_release_schedule.png
:width: 20cm
.. raw:: pdf
PageBreak standardPage
Drupal 8 vs Drupal 9
====================
* No new functionality
* Deprecated code removed
* PHP required version increased
* Major versions of dependencies updated
.. raw:: pdf
TextAnnotation "Different to previous major version updates"
TextAnnotation "Symfony upgraded from 3 to 4."
Previous upgrade issues
=======================
* Lots of breaking changes
* Core released, but contrib takes time to catch up
.. raw:: pdf
TextAnnotation "Lots of breaking changes, large rebuilds and migrations"
TextAnnotation "6(?) months between D7 core and Views being released, prevents adoption"
TextAnnotation "Jeff Geerling blog post 'Did breaking backwards compatibility kill Drupal?'"
Contrib improvements
====================
* Minimal code changes required
* Single release can support multiple versions of core
* Semantic versioning enabled for contrib projects
.. raw:: pdf
TextAnnotation "Need to fix deprecation notices, and replace deprecated code with the suggested replacements"
TextAnnotation "Modules, themes and distributions can now work with multiple versions of Drupal core in the same release"
TextAnnotation "`core` key replaced with `core_version_requirement`"
PageBreak imagePage
.. image:: images/multiple-versions.png
:width: 20cm
|
.. image:: images/semver.png
:width: 20cm
.. raw:: pdf
PageBreak titlePage
.. class:: centredtitle
The difference is deprecated code
.. raw:: pdf
TextAnnotation "Code that has been replaced by newer code and marked to be removed."
TextAnnotation "Not removed immediately to keep backwards compatibility."
TextAnnotation "A backwards compatibility break would require a major version change rather than a minor one."
PageBreak standardPage
Deprecation example
===================
.. code-block:: php
:startinline: true
function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) {
@trigger_error('drupal_set_message() is deprecated in Drupal 8.5.0 and will
be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface
::addMessage() instead. See https://www.drupal.org/node/2774931',
E_USER_DEPRECATED);
$messenger = \Drupal::messenger();
if (isset($message)) {
$messenger->addMessage($message, $type, $repeat);
}
return $messenger->all();
}
.. raw:: pdf
TextAnnotation "drupal_set_message has been replaced by a Messenger service, this should be used instead."
TextAnnotation "Works but triggers an error in 8.9, breaks in 9.0."
TextAnnotation "To ensure D9 compatibility, update all of the deprecated code."
PageBreak titlePage
.. class:: centredtitle
How do I find it?
.. raw:: pdf
PageBreak standardPage
Drupal Check
============
- Developed by Matt Glaman
- "Built on PHPStan, this static analysis tool will check for correctness (e.g. using a class that doesn't exist), deprecation errors, and more."
- https://github.com/mglaman/drupal-check
.. raw:: pdf
PageBreak titlePage
.. class:: centredtitle
``composer global require
mglaman/drupal-check``
.. page::
.. class:: centredtitle
``drupal-check web/modules/custom``
.. raw:: pdf
PageBreak imagePage
.. image:: images/drupal-check-output.png
:width: 22cm
.. raw:: pdf
PageBreak titlePage
.. class:: centredtitle
Upgrade Status module
.. raw:: pdf
PageBreak imagePage
.. image:: images/drupal-check-upgrade-status-comparison.png
:width: 12cm
.. raw:: pdf
PageBreak standardPage
PHPUnit Bridge
==============
- Drupal 8 uses Symfony's PHPUnit Bridge
- Includes a 'Deprecation Helper'
- Displays deprecation notices in test output
.. raw:: pdf
PageBreak imagePage
.. image:: images/phpunit-deprecation.png
:width: 23cm
.. raw:: pdf
PageBreak standardPage
Fixing deprecations
===================
.. code-block:: diff
- drupal_set_message($text);
+ Drupal::messenger()->addMessage($text);
.. image:: images/logo-composer-transparent.png
:width: 10cm
Composer
========
- Dependency management tool for PHP
- My preferred way to manage Drupal codebases
- composer.json lists your dependencies and version constraints
- composer.lock stores the installed dependencies and versions
- Separate packages for ``core-recommended``, ``core-dev`` and ``core-composer-scaffold``
.. raw:: pdf
TextAnnotation "Used by the majority of PHP frameworks and projects (Symfony, Laravel, Drush, Drupal Console)."
PageBreak titlePage
.. class:: centredtitle
``composer require
drupal/admin_toolbar:^2.0``
.. page::
.. class:: centredtitle
``composer install``
.. page::
.. class:: centredtitle
``composer update
drupal/admin_toolbar``
.. page::
.. class:: centredtitle
Always add '--no-dev' in production
.. raw:: pdf
TextAnnotation "Prevents development dependencies from being installed, and potential security exploits from being added."
PageBreak titlePage
.. class:: centredtitle
An Example: Dransible
.. class:: centred
https://github.com/opdavies/dransible
.. raw:: pdf
PageBreak imagePage
.. image:: images/dransible-repo.png
:width: 20cm
.. raw:: pdf
PageBreak standardPage
Upgrading Dransible
===================
- Remove Drush (temporarily)
- Update from Drupal 8.8 to 8.9
- Add Upgrade Status module
- Update contrib modules to D9 compatible versions
- Remove incompatible contrib modules (if possible)
- Fix deprecations in custom code
- Upgrade from Drupal 8.9 to 9.0
.. raw:: pdf
TextAnnotation "Without removing Drush, 8.9.0-beta2 rather than 8.9.2"
TextAnnotation "Updated Admin Toolbar module to a D9 compatible version"
TextAnnotation "Removed Config Installer as no longer needed"
TextAnnotation "Fixed deprecation warnings in custom code"
TextAnnotation "Installed Drush 10, removed and uninstalled Upgrade Status module"
PageBreak titlePage
.. class:: centredtitle
``composer update drupal/core-*
--with-dependencies``
.. page::
.. class:: centredtitle
``composer require
drupal/upgrade_status``
.. raw:: pdf
PageBreak imagePage
.. image:: images/dransible-screenshots/1.png
:width: 22cm
.. image:: images/dransible-screenshots/2.png
:width: 22cm
.. image:: images/dransible-screenshots/3.png
:width: 22cm
.. image:: images/dransible-screenshots/4.png
:width: 22cm
.. image:: images/dransible-screenshots/5.png
:width: 22cm
.. image:: images/dransible-screenshots/6.png
:width: 20cm
.. image:: images/dransible-screenshots/7.png
:width: 22cm
.. image:: images/dransible-screenshots/8.png
:width: 22cm
.. raw:: pdf
PageBreak titlePage
.. class:: centredtitle
``composer update drupal/core-*
--with-dependencies``
.. raw:: pdf
PageBreak imagePage
.. image:: images/dransible-screenshots/9.png
:width: 22cm
.. image:: images/dransible-screenshots/10.png
:width: 20cm
.. raw:: pdf
TextAnnotation "Only 6 files changed rather than hundreds or thousands"
TextAnnotation "Vast majority of the changes in composer.lock (to be expected)"
TextAnnotation "Half of the changed files are project specific. Could have been 2 or 3 files changed on some projects."
PageBreak titlePage
.. class:: centredtitle
There were some autowiring gotchas...
.. raw:: pdf
PageBreak
``Error: Class 'Symfony\Component\Config\Resource\ClassExistenceResource' not found in Symfony\Component\DependencyInjection\Compiler\AutowirePass->createTypeNotFoundMessage()``
.. page::
.. class:: centredtitle
``composer require
symfony/config:^4``
.. raw:: pdf
TextAnnotation "Composer tried installing version 5 by default, so locked to 4.x."
PageBreak titlePage
``Cannot autowire service "Drupal\simple_message\DisplaySimpleMessage": argument "$messenger" of method "__construct()" references interface "Drupal\Core\Messenger\MessengerInterface" but no such service exists. You should maybe alias this interface to the existing "messenger" service``
.. raw:: pdf
PageBreak standardPage
Fixing autowiring
=================
.. code-block:: yaml
services:
Drupal\simple_message\DisplaySimpleMessage:
autowire: true
tags:
- { name: event_subscriber }
Fixing autowiring
=================
.. code-block:: diff
services:
+ Drupal\Core\Messenger\MessengerInterface:
+ alias: messenger
+ private: true
Drupal\simple_message\DisplaySimpleMessage:
autowire: true
tags:
- { name: event_subscriber }
.. raw:: pdf
PageBreak titlePage
..
The big deal about Drupal 9 is... that it should not be a big deal
-- Dries Buytaert
.. raw:: pdf
TextAnnotation "Dransible updated in 1-2 hours."
TextAnnotation "No big rewrite."
TextAnnotation "Smallest core update PR ever!"
PageBreak standardPage
Drupal 10
=========
- Released around June 2022
- Drupal 9 EOL around November 2023
- Symfony 4 EOL in November 2023
- Another easy upgrade
.. raw:: pdf
TextAnnotation "Need to keep up to date with dependencies."
Thanks!
=======
References:
* https://www.drupal.org/docs/understanding-drupal
* https://dri.es/drupal-9-0-0-released
* https://dri.es/drupal-10-target-release-date-and-drupal-9-end-of-life
* https://github.com/opdavies/dransible
|
Me:
* https://www.oliverdavies.uk

View file

@ -0,0 +1,4 @@
Working with Workspace
######################
https://www.oliverdavies.uk/talks/working-with-workspace

View file

@ -0,0 +1,3 @@
command('say-hello <name>'): |
#!bash|=
echo ={ @('message') } from ={ input.argument('name') }

View file

@ -0,0 +1,5 @@
attribute('message'): Hello World!
command('say-hello'): |
#!bash|@
echo @('message')

View file

@ -0,0 +1,11 @@
attributes:
drupal:
docroot: web
command('apply config'): |
#!php
$ws->confd('workspace:/confd')->apply();
confd('workspace:/confd'):
- src: 'vhost.conf'
dst: 'workspace:/.my127ws/docker/nginx/default.conf'

View file

@ -0,0 +1,7 @@
command('say-hello <name>'):
env:
MESSAGE: = @('message')
NAME: = input.argument('name')
exec: |
#!bash|=
echo "$MESSAGE from $NAME"

View file

@ -0,0 +1,8 @@
# Download from GitHub.
wget https://github.com/my127/workspace/releases/download/0.1.3/ws
# Make it executable.
chmod +x ws
# Make it accessible.
mv ws /usr/local/bin

View file

@ -0,0 +1,8 @@
server {
server_name _;
root /app/{{ @('drupal.docroot' )}};
# output
server {
server_name _;
root /app/web;

View file

@ -0,0 +1,5 @@
command('say-hello'):
#!bash
run echo 'Hello World'
passthru echo 'Hello World'

View file

@ -0,0 +1,9 @@
# ws secret generate-random-key
key('default'): 'd38be3b7aa42fdbfb14c0d25f07bc1875edd5f13f640cd76'
# ws secret encrypt 'Hello World!'
attribute('message'): = decrypt('YTozOntpOjA7czo3OiJkZWZhdWx0Ijt')
command('say-hello'): |
#!bash|@
echo @('message')

View file

@ -0,0 +1,12 @@
# workspace.yml
workspace('oliverdavies-uk'):
description: My personal website codebase.
command('say-hello'):
#!bash
echo 'Hello world'
command('say-hello'):
#!php
echo 'Hello World';

View file

@ -0,0 +1,34 @@
attributes:
rst2pdf:
command: |
= 'rst2pdf ' ~ @('rst2pdf.filename.rst') ~ '
--break-level 1
--stylesheets main
--fit-background-mode scale
--extension-module preprocess
--output ' ~ @('rst2pdf.filename.pdf')
filename:
pdf: slides.pdf
rst: slides.rst
thumbnail:
filename: thumbnail.png
command('pdf generate <talk>'): |
#!bash|=
cd ={ input.argument('talk') }
passthru ={ @('rst2pdf.command') }
command('pdf watch <talk>'): |
#!bash|=
cd ={ input.argument('talk') }
passthru nodemon -e rst,style,txt -x "={ @('rst2pdf.command') }"
command('thumbnail <talk>'):
env:
PDF_FILENAME: = @('rst2pdf.filename.pdf')
THUMBNAIL_FILENAME: = @('thumbnail.filename')
exec: |
#!bash|=
cd ={ input.argument('talk') }
passthru gs -sDEVICE=png16m -r300 -dDownScaleFactor=4
-sOutputFile=$THUMBNAIL_FILENAME -dLastPage=1 $PDF_FILENAME

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View file

@ -0,0 +1,132 @@
pageSetup:
firstTemplate: coverPage
height: 18cm
margin-bottom: 0cm
margin-gutter: 0cm
margin-left: 0cm
margin-right: 0cm
margin-top: 0cm
size: null
spacing-footer: 2mm
spacing-header: 2mm
width: 32cm
pageTemplates:
coverPage:
# background: images/title.png
frames: []
[12%, 10%, 76%, 75%]
showFooter: false
showHeader: false
titlePage:
alignment: TA_CENTER
frames: []
[8%, 8%, 85%, 65%]
showFooter: true
showHeader: false
standardPage:
frames: []
[3%, 3%, 92%, 92%]
showFooter: true
showHeader: false
imagePage:
alignment: TA_CENTER
frames: []
[12%, 10%, 76%, 80%]
showFooter: true
showHeader: false
outputPage:
frames: []
[8%, 10%, 82%, 65%]
showFooter: false
showHeader: false
linkColor: #24608a
fontsAlias:
stdMono: Inconsolata-Regular
stdMonoBold: Inconsolata-Regular
stdMonoItalic: Inconsolata-Regular
styles:
normal:
fontSize: 24
leading: 32
textColor: #383745
bodytext:
alignment: TA_LEFT
heading:
fontSize: 20
spaceAfter: 16
textColor: #24608a
title:
fontSize: 300%
parent: heading
bullet-list:
commands: []
[LEFTPADDING, [0, 0], [1, -1], 10]
[RIGHTPADDING, [0, 0], [1, -1], 0]
[VALIGN, [0, 0], [-1, -1], TOP]
colWidths: ["20", null]
textColor: #aaaaaa
bullet-list-item:
spaceBefore: 14
spaceAfter: 0
titleslideinfo:
alignment: TA_CENTER
fontSize: 140%
parent: normal
footer:
alignment: TA_RIGHT
fontName: stdMono
fontSize: 20
textColor: #24608a
rightIndent: 16
spaceBefore: 0
literal:
backColor: white
fontName: stdMono
code:
backColor: white
borderWidth: 0
fontSize: 20
leading: 24
parent: literal
spaceBefore: 4
blockquote:
parent: normal
fontName: stdItalic
leading: 36
attribution:
parent: normal
textColor: #66666
centred:
alignment: TA_CENTER
parent: bodytext
centredtitle:
alignment: TA_CENTER
fontName: stdBold
fontSize: 48
leading: 64
parent: heading
text-lg:
parent: bodytext
fontSize: 150%

View file

@ -0,0 +1,222 @@
.. footer:: @opdavies
Working with Workspace
######################
|
.. class:: titleslideinfo
Oliver Davies, Inviqa
.. raw:: pdf
TextAnnotation "Full stack Developer and Systems Administrator"
TextAnnotation "Organiser of PHP South Wales"
.. page:: standardPage
What is Workspace?
==================
* A tool that we use and maintain at Inviqa
* Primarily for building and managing Docker Compose environments
* Built on Symfony
* Create custom commands for your project environments
* Alternative to a bash script or a Makefile
* And more...
.. raw:: pdf
TextAnnotation "Available on GitHub, MIT licensed."
TextAnnotation "Uses Config, Console, Dependency Injection, Expression Language, Finder and YAML components, as well as Twig."
TextAnnotation "Replacement for commands like 'make build'"
TextAnnotation "Useful for simplifying long, complicated commands, e.g. Docker, Ansible."
Features
========
* Commands
* Functions
* Attributes
* Encrypting/decrypting secrets
* Generating configuration files
* Global services: logging, mail, proxy
.. raw:: pdf
TextAnnotation "Generating settings.php files, Dockerfiles and Docker Compose from a central set of attributes."
TextAnnotation "Logging with kibana, mailhog, Traefik proxy."
Installation
============
.. code-block:: bash
:include: code/installation.txt
.. page:: imagePage
.. image:: images/output-simple.png
:width: 15cm
.. page:: titlePage
.. class:: centredtitle
Replacing your Makefile
.. page:: standardPage
Running simple commands
=======================
.. code-block:: yaml
:include: code/simple-command.txt
:linenos:
.. page:: imagePage
.. image:: images/output-command.png
:width: 15cm
.. page:: standardPage
'run' vs. 'passthru'
====================
.. code-block:: yaml
:include: code/run-passthru.txt
.. image:: images/helper-run.png
:width: 20cm
.. image:: images/helper-passthru.png
:width: 20cm
Attributes
==========
.. code-block:: yaml
:include: code/attributes.txt
:linenos:
Arguments
=========
.. code-block:: yaml
:include: code/arguments.txt
:linenos:
Environment variables
=====================
.. code-block:: yaml
:include: code/environment-variables.txt
:linenos:
Managing secrets
================
.. code-block:: yaml
:include: code/secrets.txt
.. raw:: pdf
TextAnnotation "Shortened for slides"
TextAnnotation "Store default key in an overrides file that's ignored from Git, and somewhere secure like a password manager."
.. page:: titlePage
.. class:: centredtitle
Example: building slides from rst2pdf
.. page:: standardPage
Attributes
==========
.. code-block:: yaml
:include: code/workspace-talks.txt
:end-before: command('pdf generate <talk>'): |
Generating PDFs
===============
.. code-block:: yaml
:include: code/workspace-talks.txt
:start-at: command('pdf generate <talk>'): |
:end-before: command('thumbnail <talk>'):
Generating thumbnails
=====================
.. code-block:: yaml
:include: code/workspace-talks.txt
:start-at: command('thumbnail <talk>'):
.. page:: titlePage
.. class:: centredtitle
Configuration files
.. page:: standardPage
Using confd
===========
.. code-block:: yaml
:include: code/confd.txt
:linenos:
.. raw:: pdf
TextAnnotation ".twig file extension is assumed."
vhost.conf.twig
===============
The source file.
|
.. code-block:: twig
:include: code/nginx-vhost.txt
:end-before: # output
:linenos:
default.conf
============
The generated file.
|
.. code-block:: nginx
:include: code/nginx-vhost.txt
:start-after: # output
:linenos:
.. page:: titlePage
.. class:: centredtitle
Demo: "Workspacing" my site
.. page:: standardPage
Thanks!
=======
References:
* https://github.com/my127/workspace
* https://oliverdavies.link/workspace-demo
* https://oliverdavies.link/workspacing-site
|
Me:
* https://www.oliverdavies.uk

View file

@ -0,0 +1,4 @@
Building and presenting slide decks with rst2pdf
################################################
https://www.oliverdavies.uk/talks/building-presenting-slide-decks-rst2pdf

View file

@ -0,0 +1,12 @@
rst2pdf slides.rst
rst2pdf slides.rst --break-level 1 --stylesheets main
rst2pdf slides.rst \
--output slides.pdf \
--stylesheets main \
--break-level 1 \
--fit-background-mode scale \
--extension-module preprocess

View file

@ -0,0 +1,4 @@
.. code-block:: javascript
:include: code/additional-config-options.txt
:hl_lines: 2 3 4
:linenos:

View file

@ -0,0 +1 @@
.. include:: sections/intro.rst

View file

@ -0,0 +1,3 @@
.. raw:: pdf
PageBreak standardPage

View file

@ -0,0 +1,6 @@
pageTemplates:
standardPage:
frames: []
[3%, 3%, 92%, 92%]
showFooter: true
showHeader: false

View file

@ -0,0 +1,29 @@
linkColor: #24608a
styles:
normal:
fontSize: 24
leading: 32
textColor: #383745
bodytext:
alignment: TA_LEFT
heading:
fontSize: 20
spaceAfter: 16
textColor: #24608a
title:
fontSize: 300%
parent: heading
textColor: white
bullet-list:
commands: []
[LEFTPADDING, [0, 0], [1, -1], 10]
[RIGHTPADDING, [0, 0], [1, -1], 0]
[VALIGN, [0, 0], [-1, -1], TOP]
colWidths: ["20", null]
textColor: #aaaaaa

View file

@ -0,0 +1,14 @@
Building and presenting slide decks with rst2pdf
################################################
.. class:: titleslideinfo
Oliver Davies (@opdavies)
What is rst2pdf?
================
* "Use a text editor. Make a PDF."
* reStructuredText to PDF
* Each slide is a page

View file

@ -0,0 +1,14 @@
.. image:: images/editing.png
:width: 20cm
.. code-block:: php
:startinline: true
:linenos:
echo 'Hello world!';
.. raw:: pdf
TextAnnotation "This is a speaker note."

View file

@ -0,0 +1,8 @@
nodemon --ext rst,style,txt --exec "
rst2pdf slides.rst \
--output slides.pdf \
--stylesheets main \
--break-level 1 \
--fit-background-mode scale \
--extension-module preprocess
"

Some files were not shown because too many files have changed in this diff Show more