Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Automating deployments from GitHub using SaltStack

205 views

Published on

2018/12/10に開催されたLINE Developer Meetup #47 in Fukuokaでの登壇資料です

Published in: Technology
  • Be the first to comment

Automating deployments from GitHub using SaltStack

  1. 1. Automating deployments from GitHub using SaltStack Paul Traylor LINE Fukuoka 2018/12/10 LINE Developer Meetup #47 in Fukuoka 1 / 14
  2. 2. What is SaltStack? Salt is a new approach to infrastructure management built on a dynamic communication bus. Salt can be used for data-driven orchestration, remote execution for any infrastructure, configuration management for any app stack, and much more. https://docs.saltstack.com/en/getstarted/overview.html https://docs.saltstack.com/en/getstarted/images/basic-comm.png 2 / 14
  3. 3. What is SaltStack? - Events https://docs.saltstack.com/en/getstarted/images/reactor.png 3 / 14
  4. 4. What is SaltStack? - Events salt-run state.event pretty=True salt/auth salt/key salt/job/<JID>/new salt/job/<JID>/ret/<MINION> salt/run/<JID>/new salt/run/<JID>/ret salt/beacon/... salt/job/20150923203228234305/ret/minion2 { "_stamp": "2015-09-23T20:32:28.291789", "cmd": "_return", "fun": "test.ping", "fun_args": [], "id": "minion2", "jid": "20150923203228234305", "retcode": 0, "return": true, "success": true } https://docs.saltstack.com/en/getstarted/event/events.html 4 / 14
  5. 5. What is SaltStack? - Reactor https://docs.saltstack.com/en/latest/topics/reactor/ reactor: # Master config section "reactor" - 'salt/minion/*/start': # Match tag "salt/minion/*/start" - /srv/reactor/start.sls # Things to do when a minion starts - /srv/reactor/monitor.sls # Other things to do - 'salt/cloud/*/destroyed': # Globs can be used to match tags - /srv/reactor/destroy/*.sls # Globs can be used to match file names - 'myco/custom/event/tag': # React to custom event tags - salt://reactor/mycustom.sls # Reactor files can come from the salt fileserver 5 / 14
  6. 6. What is SaltStack? - Returners https://docs.saltstack.com/en/getstarted/images/returners.png 6 / 14
  7. 7. What is SaltStack? - Returners http://docs.saltstack.com/en/latest/ref/returners/ elasticsearch kafka mongo mysql postgres redis ... 7 / 14
  8. 8. How do we use this ? Events Returners Reactors 8 / 14
  9. 9. Events - Enable Webhooks # salt-master configuration # Load a simple webhook so that we can easily map GitHub webhooks # to our salt state engines: - webhook: {} http://docs.saltstack.com/en/latest/ref/engines/all/salt.engines.webhook.html 9 / 14
  10. 10. Events - GitHub Webhooks Post to our Salt Master will fire an event curl -X POST http://salt.example.com/github <<EOF {webhook json body} EOF is put onto the Salt event bus salt/engines/hook/github {webhook json body} 10 / 14
  11. 11. Reactors - Map our event to a reactor # salt-master configuration reactor: - 'salt/engines/hook/github': - salt://_reactor/autodeploy.sls 11 / 14
  12. 12. Reactors - Write our Reactor #!yaml|github # salt://_reactor/autodeploy.sls # Whenever we update Promgen line/promgen: # we want to deploy the master branch refs/heads/master: deploy-promgen-web: # by applying a salt state local.state.sls: # matching our promgen servers - tgt: role:promgen - tgt_type: pillar - args: - mods: promgen.web # and let me know the result on slack - ret: slack https://github.com/kfdm/salt-deployhook 12 / 14
  13. 13. What is SaltStack ? Events Returners Reactors Automate your infrastructure 13 / 14
  14. 14. Questions? https://linefukuoka.co.jp/ja/career/engineer 14 / 14

×