{"id":34969,"date":"2024-09-11T15:48:02","date_gmt":"2024-09-11T08:48:02","guid":{"rendered":"http:\/\/jupitek.maudemo.vip\/index.php\/2024\/09\/11\/automate-static-site-deployments-with-salt-git-and-webhooks\/"},"modified":"2024-09-11T15:48:02","modified_gmt":"2024-09-11T08:48:02","slug":"automate-static-site-deployments-with-salt-git-and-webhooks","status":"publish","type":"post","link":"https:\/\/jupitek.maudemo.vip\/index.php\/2024\/09\/11\/automate-static-site-deployments-with-salt-git-and-webhooks\/","title":{"rendered":"T\u1ef1 \u0111\u1ed9ng tri\u1ec3n khai trang t\u0129nh v\u1edbi Salt, Git, v\u00e0 Webhooks"},"content":{"rendered":"<p>H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1ebd h\u01b0\u1edbng d\u1eabn tri\u1ec3n khai site t\u0129nh b\u1eb1ng&nbsp;<a href=\"https:\/\/github.com\/saltstack\/salt\" target=\"_blank\" rel=\"noreferrer noopener\">SaltStack<\/a>&nbsp;, \u0111\u00e2y l\u00e0 h\u1ec7 th\u1ed1ng qu\u1ea3n l\u00fd c\u1ea5u h\u00ecnh linh ho\u1ea1t. C\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh \u0111\u01b0\u1ee3c t\u1ea1o cho Salt s\u1ebd \u0111\u01b0\u1ee3c ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n b\u1eb1ng Git. C\u00e1c b\u1ea3n c\u1eadp nh\u1eadt cho m\u00e3 site t\u0129nh c\u1ee7a b\u1ea1n s\u1ebd \u0111\u01b0\u1ee3c t\u1ef1 \u0111\u1ed9ng truy\u1ec1n \u0111\u1ebfn h\u1ec7 th\u1ed1ng s\u1ea3n xu\u1ea5t b\u1eb1ng webhooks, m\u1ed9t h\u1ec7 th\u1ed1ng th\u00f4ng b\u00e1o s\u1ef1 ki\u1ec7n cho web.<\/p>\n<p>Vi\u1ec7c thi\u1ebft l\u1eadp c\u00e1c c\u01a1 ch\u1ebf n\u00e0y mang l\u1ea1i nhi\u1ec1u l\u1ee3i \u00edch:<\/p>\n<ul>\n<li>S\u1eed d\u1ee5ng webhooks s\u1ebd gi\u00fap trang web s\u1ea3n xu\u1ea5t c\u1ee7a b\u1ea1n \u0111\u1ed3ng b\u1ed9 v\u1edbi qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n m\u00e0 kh\u00f4ng c\u1ea7n b\u1ea1n ph\u1ea3i th\u1ef1c hi\u1ec7n b\u1ea5t k\u1ef3 thao t\u00e1c n\u00e0o.<\/li>\n<li>S\u1eed d\u1ee5ng Salt cung c\u1ea5p m\u1ed9t gi\u1ea3i ph\u00e1p \u0111\u00e1ng tin c\u1eady v\u00e0 c\u00f3 th\u1ec3 m\u1edf r\u1ed9ng \u0111\u1ec3 thay \u0111\u1ed5i h\u1ec7 th\u1ed1ng s\u1ea3n xu\u1ea5t c\u1ee7a b\u1ea1n v\u00e0 gi\u1ea3m thi\u1ec3u l\u1ed7i c\u1ee7a con ng\u01b0\u1eddi.<\/li>\n<li>Ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n qu\u1ea3n l\u00fd c\u1ea5u h\u00ecnh gi\u00fap b\u1ea1n theo d\u00f5i ho\u1eb7c kh\u00f4i ph\u1ee5c nh\u1eefng thay \u0111\u1ed5i \u0111\u00e3 th\u1ef1c hi\u1ec7n \u0111\u1ed1i v\u1edbi h\u1ec7 th\u1ed1ng c\u1ee7a m\u00ecnh v\u00e0 c\u1ed9ng t\u00e1c v\u1edbi nh\u1eefng ng\u01b0\u1eddi kh\u00e1c trong qu\u00e1 tr\u00ecnh tri\u1ec3n khai.<\/li>\n<\/ul>\n<h2 id=\"development-and-deployment-workflow\">Quy tr\u00ecnh ph\u00e1t tri\u1ec3n v\u00e0 tri\u1ec3n khai<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#development-and-deployment-workflow\"><\/a><\/h2>\n<p>Tr\u00ecnh t\u1ea1o trang t\u0129nh \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong h\u01b0\u1edbng d\u1eabn n\u00e0y l\u00e0&nbsp;<a href=\"https:\/\/gohugo.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Hugo<\/a>&nbsp;, m\u1ed9t khu\u00f4n kh\u1ed5 nhanh \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng Go. Tr\u00ecnh t\u1ea1o trang t\u0129nh bi\u00ean d\u1ecbch&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Markdown\" target=\"_blank\" rel=\"noreferrer noopener\">Markdown<\/a>&nbsp;ho\u1eb7c c\u00e1c t\u1ec7p n\u1ed9i dung kh\u00e1c th\u00e0nh c\u00e1c t\u1ec7p HTML. H\u01b0\u1edbng d\u1eabn n\u00e0y c\u00f3 th\u1ec3 d\u1ec5 d\u00e0ng \u0111\u01b0\u1ee3c \u0111i\u1ec1u ch\u1ec9nh cho c\u00e1c khu\u00f4n kh\u1ed5 kh\u00e1c.<\/p>\n<p>Hai kho l\u01b0u tr\u1eef Git s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o: m\u1ed9t kho s\u1ebd theo d\u00f5i c\u00e1c thay \u0111\u1ed5i tr\u00ean trang Hugo v\u00e0 kho c\u00f2n l\u1ea1i s\u1ebd theo d\u00f5i c\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh c\u1ee7a Salt. Kho l\u01b0u tr\u1eef t\u1eeb xa s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o cho c\u1ea3 hai kho tr\u00ean GitHub.<\/p>\n<p>Hai Linode s\u1ebd \u0111\u01b0\u1ee3c t\u1ea1o: m\u1ed9t s\u1ebd ho\u1ea1t \u0111\u1ed9ng nh\u01b0 Salt master, v\u00e0 m\u1ed9t s\u1ebd ho\u1ea1t \u0111\u1ed9ng nh\u01b0 Salt minion. H\u01b0\u1edbng d\u1eabn n\u00e0y \u0111\u00e3 \u0111\u01b0\u1ee3c th\u1eed nghi\u1ec7m tr\u00ean Debian 9, nh\u01b0ng c\u00e1c h\u01b0\u1edbng d\u1eabn c\u0169ng c\u00f3 th\u1ec3 ho\u1ea1t \u0111\u1ed9ng v\u1edbi c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i kh\u00e1c. Salt minion s\u1ebd ch\u1ea1y m\u00e1y ch\u1ee7 web s\u1ea3n xu\u1ea5t ph\u1ee5c v\u1ee5 cho trang Hugo, v\u00e0 master s\u1ebd c\u1ea5u h\u00ecnh ph\u1ea7n m\u1ec1m c\u1ee7a minion. Minion c\u0169ng s\u1ebd ch\u1ea1y m\u00e1y ch\u1ee7 webhook s\u1ebd nh\u1eadn th\u00f4ng b\u00e1o c\u1eadp nh\u1eadt m\u00e3 t\u1eeb GitHub.<\/p>\n<p>C\u00f3 th\u1ec3 ch\u1ea1y Salt \u1edf&nbsp;<a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/tutorials\/quickstart.html\" target=\"_blank\" rel=\"noreferrer noopener\">ch\u1ebf \u0111\u1ed9 kh\u00f4ng c\u00f3 m\u00e1y ch\u1ee7 ch\u00ednh<\/a>&nbsp;, nh\u01b0ng s\u1eed d\u1ee5ng m\u00e1y ch\u1ee7 ch\u00ednh Salt s\u1ebd gi\u00fap b\u1ea1n d\u1ec5 d\u00e0ng m\u1edf r\u1ed9ng tri\u1ec3n khai trong t\u01b0\u01a1ng lai.<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: <a href=\"https:\/\/github.com\/linode\/docs\" target=\"_blank\" rel=\"noreferrer noopener\">Quy tr\u00ecnh l\u00e0m vi\u1ec7c \u0111\u01b0\u1ee3c m\u00f4 t\u1ea3 trong h\u01b0\u1edbng d\u1eabn n\u00e0y t\u01b0\u01a1ng t\u1ef1 nh\u01b0 c\u00e1ch ph\u00e1t tri\u1ec3n v\u00e0 tri\u1ec3n khai trang web H\u01b0\u1edbng d\u1eabn &amp; H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng<\/a>&nbsp;c\u1ee7a Linode&nbsp;.<\/p>\n<h2 id=\"before-you-begin\">Tr\u01b0\u1edbc khi b\u1ea1n b\u1eaft \u0111\u1ea7u<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#before-you-begin\"><\/a><\/h2>\n<h3 id=\"set-up-the-development-environment\">Thi\u1ebft l\u1eadp m\u00f4i tr\u01b0\u1eddng ph\u00e1t tri\u1ec3n<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#set-up-the-development-environment\"><\/a><\/h3>\n<p>Vi\u1ec7c ph\u00e1t tri\u1ec3n trang Hugo v\u00e0 c\u00f4ng th\u1ee9c Salt c\u1ee7a b\u1ea1n s\u1ebd di\u1ec5n ra tr\u00ean m\u00e1y t\u00ednh c\u00e1 nh\u00e2n c\u1ee7a b\u1ea1n. M\u1ed9t s\u1ed1 ph\u1ea7n m\u1ec1m s\u1ebd c\u1ea7n \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t tr\u00ean m\u00e1y t\u00ednh c\u1ee7a b\u1ea1n tr\u01b0\u1edbc:<\/p>\n<p>1.C\u00e0i \u0111\u1eb7t Git b\u1eb1ng m\u1ed9t trong c\u00e1c ph\u01b0\u01a1ng ph\u00e1p trong&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/how-to-install-git-on-linux-mac-and-windows\/\">h\u01b0\u1edbng d\u1eabn c\u1ee7a Linode<\/a>&nbsp;. N\u1ebfu b\u1ea1n c\u00f3 m\u00e1y Mac, h\u00e3y s\u1eed d\u1ee5ng ph\u01b0\u01a1ng ph\u00e1p Homebrew v\u00ec n\u00f3 c\u0169ng s\u1ebd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 c\u00e0i \u0111\u1eb7t Hugo.<\/p>\n<p>2.C\u00e0i \u0111\u1eb7t Hugo.&nbsp;<a href=\"https:\/\/gohugo.io\/getting-started\/installing\/\" target=\"_blank\" rel=\"noreferrer noopener\">T\u00e0i li\u1ec7u Hugo<\/a>&nbsp;c\u00f3 danh s\u00e1ch \u0111\u1ea7y \u0111\u1ee7 c\u00e1c ph\u01b0\u01a1ng ph\u00e1p c\u00e0i \u0111\u1eb7t v\u00e0 h\u01b0\u1edbng d\u1eabn cho m\u1ed9t s\u1ed1 n\u1ec1n t\u1ea3ng ph\u1ed5 bi\u1ebfn nh\u01b0 sau:<\/p>\n<pre class=\"wp-block-code\"><code>-   Debian\/Ubuntu:\n\n        sudo apt-get install hugo\n\n-   Fedora, Red Hat and CentOS:\n\n        sudo dnf install hugo\n\n-   Mac, using &#91;Homebrew](https:\/\/brew.sh):\n\n        brew install hugo\n\n-   Windows, using &#91;Chocolatey](https:\/\/chocolatey.org)\n\n        choco install hugo -confirm<\/code><\/pre>\n<h3 id=\"deploy-the-linodes\">Tri\u1ec3n khai Linodes<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#deploy-the-linodes\"><\/a><\/h3>\n<ol>\n<li>L\u00e0m theo h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/create\/\">T\u1ea1o phi\u00ean b\u1ea3n m\u00e1y t\u00ednh<\/a>&nbsp;v\u00e0 tri\u1ec3n khai hai Linode ch\u1ea1y Debian 9.<\/li>\n<li>Trong tab c\u00e0i \u0111\u1eb7t c\u1ee7a b\u1ea3ng \u0111i\u1ec1u khi\u1ec3n Linodes, h\u00e3y g\u1eafn nh\u00e3n m\u1ed9t trong&nbsp;<code>salt-master<\/code>hai Linodes l\u00e0&nbsp;<code>salt-minion<\/code>. \u0110i\u1ec1u n\u00e0y kh\u00f4ng b\u1eaft bu\u1ed9c nh\u01b0ng s\u1ebd gi\u00fap theo d\u00f5i Linode n\u00e0o ph\u1ee5c v\u1ee5 m\u1ee5c \u0111\u00edch n\u00e0o.<\/li>\n<li>Ho\u00e0n t\u1ea5t h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/set-up-and-secure\/\">Thi\u1ebft l\u1eadp v\u00e0 b\u1ea3o m\u1eadt phi\u00ean b\u1ea3n m\u00e1y t\u00ednh<\/a>&nbsp;&nbsp;tr\u00ean m\u1ed7i Linode \u0111\u1ec3 t\u1ea1o t\u00e0i kho\u1ea3n ng\u01b0\u1eddi d\u00f9ng Linux gi\u1edbi h\u1ea1n v\u1edbi&nbsp;<code>sudo<\/code>nhi\u1ec1u \u0111\u1eb7c quy\u1ec1n, t\u0103ng c\u01b0\u1eddng quy\u1ec1n truy c\u1eadp SSH v\u00e0 x\u00f3a c\u00e1c d\u1ecbch v\u1ee5 m\u1ea1ng kh\u00f4ng c\u1ea7n thi\u1ebft.Ghi ch\u00faH\u01b0\u1edbng d\u1eabn n\u00e0y \u0111\u01b0\u1ee3c vi\u1ebft cho ng\u01b0\u1eddi d\u00f9ng kh\u00f4ng ph\u1ea3i root. C\u00e1c l\u1ec7nh y\u00eau c\u1ea7u quy\u1ec1n n\u00e2ng cao \u0111\u01b0\u1ee3c th\u00eam ti\u1ec1n t\u1ed1&nbsp;<code>sudo<\/code>. N\u1ebfu b\u1ea1n kh\u00f4ng quen v\u1edbi&nbsp;<code>sudo<\/code>l\u1ec7nh n\u00e0y, h\u00e3y truy c\u1eadp h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/linux-users-and-groups\/\">Ng\u01b0\u1eddi d\u00f9ng v\u00e0 Nh\u00f3m<\/a>&nbsp;c\u1ee7a ch\u00fang t\u00f4i .T\u1ea5t c\u1ea3 c\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh ph\u1ea3i \u0111\u01b0\u1ee3c ch\u1ec9nh s\u1eeda v\u1edbi quy\u1ec1n cao h\u01a1n. H\u00e3y nh\u1edb bao g\u1ed3m&nbsp;<code>sudo<\/code>tr\u01b0\u1edbc khi ch\u1ea1y tr\u00ecnh so\u1ea1n th\u1ea3o v\u0103n b\u1ea3n c\u1ee7a b\u1ea1n.<\/li>\n<li>C\u1ea5u h\u00ecnh DNS cho trang web c\u1ee7a b\u1ea1n b\u1eb1ng c\u00e1ch th\u00eam&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/networking\/dns-manager\/guides\/create-domain\/\">v\u00f9ng mi\u1ec1n<\/a>&nbsp;v\u00e0 thi\u1ebft l\u1eadp&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/configure-rdns\/\">DNS ng\u01b0\u1ee3c<\/a>&nbsp;tr\u00ean \u0111\u1ecba ch\u1ec9 IP c\u1ee7a Salt minion.<\/li>\n<\/ol>\n<h2 id=\"set-up-the-salt-master-and-salt-minion\">Thi\u1ebft l\u1eadp Salt Master v\u00e0 Salt Minion<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#set-up-the-salt-master-and-salt-minion\"><\/a><\/h2>\n<p>Tr\u01b0\u1edbc khi b\u1ea1n c\u00f3 th\u1ec3 b\u1eaft \u0111\u1ea7u thi\u1ebft l\u1eadp c\u00f4ng th\u1ee9c Salt cho minion, tr\u01b0\u1edbc ti\u00ean b\u1ea1n c\u1ea7n c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m Salt tr\u00ean m\u00e1y ch\u1ee7 v\u00e0 minion v\u00e0 thi\u1ebft l\u1eadp giao ti\u1ebfp gi\u1eefa ch\u00fang.<\/p>\n<p>1.\u0110\u0103ng nh\u1eadp v\u00e0o Salt&nbsp;<strong>master<\/strong>&nbsp;Linode qua SSH v\u00e0 ch\u1ea1y t\u1eadp l\u1ec7nh kh\u1edfi \u0111\u1ed9ng c\u00e0i \u0111\u1eb7t Salt:<\/p>\n<pre class=\"wp-block-code\"><code>wget -O bootstrap-salt.sh https:\/\/bootstrap.saltproject.io\nsudo sh bootstrap-salt.sh -M -N<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: T\u00f9y ch\u1ecdn n\u00e0y&nbsp;<code>-M<\/code>y\u00eau c\u1ea7u t\u1eadp l\u1ec7nh c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m Salt master v\u00e0&nbsp;<code>-N<\/code>t\u00f9y ch\u1ecdn n\u00e0y y\u00eau c\u1ea7u t\u1eadp l\u1ec7nh kh\u00f4ng c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m minion.<\/p>\n<p>2.\u0110\u0103ng nh\u1eadp v\u00e0o Linode Salt&nbsp;<strong>minion<\/strong>&nbsp;qua SSH v\u00e0&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/set-up-and-secure\/#configure-a-custom-hostname\">\u0111\u1eb7t t\u00ean m\u00e1y ch\u1ee7<\/a>&nbsp;. H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1eed d\u1ee5ng&nbsp;<code>hugo-webserver<\/code>t\u00ean m\u00e1y ch\u1ee7 l\u00e0m v\u00ed d\u1ee5:<\/p>\n<pre class=\"wp-block-code\"><code>sudo hostnamectl set-hostname hugo-webserver<\/code><\/pre>\n<p>Ghi ch\u00fa: B\u01b0\u1edbc n\u00e0y c\u1ea7n ph\u1ea3i \u0111\u01b0\u1ee3c ho\u00e0n t\u1ea5t&nbsp;<strong>tr\u01b0\u1edbc khi c\u00e0i \u0111\u1eb7t Salt<\/strong>&nbsp;tr\u00ean minion v\u00ec Salt s\u1ebd s\u1eed d\u1ee5ng t\u00ean m\u00e1y ch\u1ee7 c\u1ee7a b\u1ea1n \u0111\u1ec3 t\u1ea1o Salt ID cho minion.<\/p>\n<p>3.Ch\u1ec9nh s\u1eeda t\u1ec7p c\u1ee7a minion&nbsp;<code>\/etc\/hosts<\/code>v\u00e0 th\u00eam m\u1ed9t d\u00f2ng m\u1edbi cho t\u00ean m\u00e1y ch\u1ee7 c\u1ee7a b\u1ea1n sau&nbsp;<code>localhost<\/code>d\u00f2ng \u0111\u00f3; thay th\u1ebf 192.0.2.3 b\u1eb1ng&nbsp;\u0111\u1ecba ch\u1ec9 IP c\u00f4ng khai&nbsp;<strong>c\u1ee7a minion :<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>127.0.0.1       localhost\n192.0.2.3       hugo-webserver\n# &#91;...]<\/code><\/pre>\n<p>4.Ch\u1ea1y t\u1eadp l\u1ec7nh bootstrap tr\u00ean minion:<\/p>\n<pre class=\"wp-block-code\"><code>wget -O bootstrap-salt.sh https:\/\/bootstrap.saltproject.io\nsudo sh bootstrap-salt.sh<\/code><\/pre>\n<p>5.Ch\u1ec9nh s\u1eeda&nbsp;<code>\/etc\/salt\/minion<\/code>tr\u00ean Salt minion. B\u1ecf ch\u00fa th\u00edch d\u00f2ng b\u1eaft \u0111\u1ea7u b\u1eb1ng&nbsp;<code>#master:<\/code>v\u00e0 nh\u1eadp IP c\u1ee7a Salt&nbsp;<strong>master<\/strong>&nbsp;sau d\u1ea5u hai ch\u1ea5m (thay cho&nbsp;<code>192.0.2.2<\/code>):<\/p>\n<pre class=\"wp-block-code\"><code># &#91;...]\nmaster: 192.0.2.2\n# &#91;...]<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: Linode kh\u00f4ng t\u00ednh ph\u00ed l\u01b0u l\u01b0\u1ee3ng truy c\u1eadp trong trung t\u00e2m d\u1eef li\u1ec7u qua c\u00e1c \u0111\u1ecba ch\u1ec9 IP ri\u00eang. N\u1ebfu Salt master v\u00e0 minion c\u1ee7a b\u1ea1n n\u1eb1m trong c\u00f9ng m\u1ed9t trung t\u00e2m d\u1eef li\u1ec7u v\u00e0 c\u1ea3 hai \u0111\u1ec1u c\u00f3 \u0111\u1ecba ch\u1ec9 IP ri\u00eang, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng \u0111\u1ecba ch\u1ec9 IP ri\u00eang c\u1ee7a Salt master trong b\u01b0\u1edbc n\u00e0y \u0111\u1ec3 tr\u00e1nh ph\u1ea3i ch\u1ecbu ph\u00ed l\u01b0u l\u01b0\u1ee3ng d\u1eef li\u1ec7u.<\/p>\n<p>6.Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Salt tr\u00ean minion:<\/p>\n<pre class=\"wp-block-code\"><code>sudo systemctl restart salt-minion\n<\/code><\/pre>\n<h3 id=\"salt-minion-authentication\">X\u00e1c th\u1ef1c Salt Minion<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#salt-minion-authentication\"><\/a><\/h3>\n<p>B\u00e2y gi\u1edd, minion c\u00f3 th\u1ec3 t\u00ecm th\u1ea5y master, nh\u01b0ng v\u1eabn ch\u01b0a \u0111\u01b0\u1ee3c x\u00e1c th\u1ef1c \u0111\u1ec3 giao ti\u1ebfp v\u1edbi master. Salt s\u1eed d\u1ee5ng c\u1eb7p kh\u00f3a c\u00f4ng khai-ri\u00eang t\u01b0 \u0111\u1ec3 x\u00e1c th\u1ef1c minion v\u1edbi master.<\/p>\n<p>1.Tr\u00ean m\u00e1y&nbsp;<strong>ch\u1ee7 ch\u00ednh<\/strong>&nbsp;, li\u1ec7t k\u00ea d\u1ea5u v\u00e2n tay cho t\u1ea5t c\u1ea3 c\u00e1c kh\u00f3a c\u1ee5c b\u1ed9 c\u1ee7a m\u00e1y ch\u1ee7 ch\u00ednh, c\u00e1c kh\u00f3a minion \u0111\u01b0\u1ee3c ch\u1ea5p nh\u1eadn v\u00e0 c\u00e1c kh\u00f3a kh\u00f4ng \u0111\u01b0\u1ee3c ch\u1ea5p nh\u1eadn:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt-key --finger-all\n<\/code><\/pre>\n<p>\u0110\u1ea7u ra s\u1ebd gi\u1ed1ng nh\u01b0 sau:<\/p>\n<pre class=\"wp-block-code\"><code>Local Keys:\nmaster.pem:  fe:1f:e8:3d:26:83:1c:...\nmaster.pub:  2b:93:72:b3:3a:ae:cb:...\nUnaccepted Keys:\nhugo-webserver:  29:d8:f3:ed:91:9b:51:...<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: C\u00e1c d\u1ea5u v\u00e2n tay m\u1eabu trong ph\u1ea7n n\u00e0y \u0111\u00e3 \u0111\u01b0\u1ee3c c\u1eaft b\u1edbt \u0111\u1ec3 ng\u1eafn g\u1ecdn h\u01a1n.<\/p>\n<p>2.Sao ch\u00e9p d\u1ea5u v\u00e2n tay&nbsp;<code>master.pub<\/code>t\u1eeb \u0111\u1ea7u ra c\u1ee7a&nbsp;<code>salt-key --finger-all<\/code>. Tr\u00ean Salt&nbsp;<strong>minion<\/strong>&nbsp;c\u1ee7a b\u1ea1n , m\u1edf&nbsp;<code>\/etc\/salt\/minion<\/code>trong tr\u00ecnh so\u1ea1n th\u1ea3o v\u0103n b\u1ea3n. B\u1ecf ch\u00fa th\u00edch d\u00f2ng b\u1eaft \u0111\u1ea7u b\u1eb1ng&nbsp;<code>#master_finger:<\/code>v\u00e0 nh\u1eadp gi\u00e1 tr\u1ecb cho&nbsp;<code>master.pub<\/code>sau d\u1ea5u hai ch\u1ea5m trong d\u1ea5u ngo\u1eb7c \u0111\u01a1n:<\/p>\n<pre class=\"wp-block-code\"><code># &#91;...]\nmaster_finger: '0f:d6:5f:5e:f3:4f:d3:...'\n# &#91;...]<\/code><\/pre>\n<p>3.Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Salt tr\u00ean minion:<\/p>\n<pre class=\"wp-block-code\"><code>sudo systemctl restart salt-minion\n<\/code><\/pre>\n<p>4.Xem d\u1ea5u v\u00e2n tay kh\u00f3a c\u1ee5c b\u1ed9 c\u1ee7a minion:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt-call key.finger --local\n<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>local:\n    29:d8:f3:ed:91:9b:51:...\n<\/code><\/pre>\n<p>So s\u00e1nh d\u1ea5u v\u00e2n tay \u0111\u01b0\u1ee3c li\u1ec7t k\u00ea c\u1ee7a \u0111\u1ea7u ra v\u1edbi d\u1ea5u v\u00e2n tay \u0111\u01b0\u1ee3c li\u1ec7t k\u00ea b\u1edfi Salt master cho b\u1ea5t k\u1ef3&nbsp;<code>Unaccepted Keys<\/code>. \u0110\u00e2y l\u00e0 \u0111\u1ea7u ra c\u1ee7a&nbsp;<code>salt-key --finger-all<\/code>l\u1ec7nh ch\u1ea1y tr\u00ean master \u1edf \u0111\u1ea7u ph\u1ea7n n\u00e0y.<\/p>\n<p>5.Sau khi x\u00e1c minh d\u1ea5u v\u00e2n tay c\u1ee7a minion gi\u1ed1ng v\u1edbi d\u1ea5u v\u00e2n tay \u0111\u01b0\u1ee3c Salt master ph\u00e1t hi\u1ec7n, h\u00e3y ch\u1ea1y l\u1ec7nh sau tr\u00ean&nbsp;<strong>master<\/strong>&nbsp;\u0111\u1ec3 ch\u1ea5p nh\u1eadn kh\u00f3a c\u1ee7a minion:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt-key -a hugo-webserver\n<\/code><\/pre>\n<p>6.T\u1eeb m\u00e1y ch\u1ee7, h\u00e3y x\u00e1c minh r\u1eb1ng minion \u0111ang ch\u1ea1y:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt-run manage.up\n<\/code><\/pre>\n<p>B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 ch\u1ea1y l\u1ec7nh ping ki\u1ec3m tra Salt t\u1eeb m\u00e1y ch\u1ee7 \u0111\u1ebfn m\u00e1y con:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt 'hugo-webserver' test.ping<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>hugo-webserver:\n    True\n<\/code><\/pre>\n<h2 id=\"initialize-the-salt-minions-formula\">Kh\u1edfi t\u1ea1o c\u00f4ng th\u1ee9c c\u1ee7a Salt Minion<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#initialize-the-salt-minions-formula\"><\/a><\/h2>\n<p>Minion Salt \u0111\u00e3 s\u1eb5n s\u00e0ng \u0111\u1ec3 \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh b\u1edfi master. C\u00e1c c\u1ea5u h\u00ecnh n\u00e0y s\u1ebd \u0111\u01b0\u1ee3c vi\u1ebft trong&nbsp;<em>c\u00f4ng th\u1ee9c<\/em>&nbsp;Salt s\u1ebd \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef tr\u00ean&nbsp;<a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a>&nbsp;.<\/p>\n<p>1.Tr\u00ean m\u00e1y t\u00ednh c\u1ee7a b\u1ea1n, h\u00e3y t\u1ea1o m\u1ed9t th\u01b0 m\u1ee5c m\u1edbi \u0111\u1ec3 l\u01b0u c\u00f4ng th\u1ee9c c\u1ee7a minion v\u00e0 chuy\u1ec3n \u0111\u1ebfn th\u01b0 m\u1ee5c \u0111\u00f3:<\/p>\n<pre class=\"wp-block-code\"><code>mkdir hugo-webserver-salt-formula\ncd hugo-webserver-salt-formula<\/code><\/pre>\n<p>2.B\u00ean trong th\u01b0 m\u1ee5c c\u00f4ng th\u1ee9c, t\u1ea1o m\u1ed9t&nbsp;<code>hugo<\/code>th\u01b0 m\u1ee5c m\u1edbi \u0111\u1ec3 l\u01b0u tr\u1eef c\u1ea5u h\u00ecnh m\u00e1y ch\u1ee7 web c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>mkdir hugo\n<\/code><\/pre>\n<p>3.B\u00ean trong th\u01b0&nbsp;<code>hugo<\/code>m\u1ee5c, t\u1ea1o m\u1ed9t t\u1ec7p m\u1edbi&nbsp;<code>install.sls<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>nginx_pkg:\n  pkg.installed:\n    - name: nginx<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: C\u1ea5u h\u00ecnh Salt \u0111\u01b0\u1ee3c khai b\u00e1o trong YAML \u2013 m\u1ed9t ng\u00f4n ng\u1eef \u0111\u00e1nh d\u1ea5u k\u1ebft h\u1ee3p kho\u1ea3ng tr\u1eafng\/th\u1ee5t l\u1ec1 trong c\u00fa ph\u00e1p c\u1ee7a n\u00f3. H\u00e3y \u0111\u1ea3m b\u1ea3o s\u1eed d\u1ee5ng c\u00f9ng m\u1ed9t th\u1ee5t l\u1ec1 nh\u01b0 c\u00e1c \u0111o\u1ea1n tr\u00edch \u0111\u01b0\u1ee3c tr\u00ecnh b\u00e0y trong h\u01b0\u1edbng d\u1eabn n\u00e0y.<\/p>\n<p>M\u1ed9t&nbsp;<code>.sls<\/code>t\u1ec7p l\u00e0 t\u1ec7p&nbsp;<strong>S<\/strong>&nbsp;a&nbsp;<strong>L<\/strong>&nbsp;t&nbsp;<strong>S<\/strong>&nbsp;state. Tr\u1ea1ng th\u00e1i Salt m\u00f4 t\u1ea3 tr\u1ea1ng th\u00e1i m\u00e0 m\u1ed9t minion ph\u1ea3i c\u00f3 sau khi tr\u1ea1ng th\u00e1i \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng cho n\u00f3: v\u00ed d\u1ee5, t\u1ea5t c\u1ea3 ph\u1ea7n m\u1ec1m c\u1ea7n \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t, t\u1ea5t c\u1ea3 c\u00e1c d\u1ecbch v\u1ee5 c\u1ea7n \u0111\u01b0\u1ee3c ch\u1ea1y, v.v.<\/p>\n<p>\u0110o\u1ea1n m\u00e3 tr\u00ean cho bi\u1ebft m\u1ed9t g\u00f3i c\u00f3 t\u00ean&nbsp;<code>nginx<\/code>(t\u1ee9c l\u00e0 m\u00e1y ch\u1ee7 web NGINX) ph\u1ea3i \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t th\u00f4ng qua tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i c\u1ee7a b\u1ea3n ph\u00e2n ph\u1ed1i. Salt bi\u1ebft c\u00e1ch \u0111\u00e0m ph\u00e1n c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m th\u00f4ng qua tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i t\u00edch h\u1ee3p cho nhi\u1ec1u b\u1ea3n ph\u00e2n ph\u1ed1i kh\u00e1c nhau. Salt c\u0169ng bi\u1ebft c\u00e1ch c\u00e0i \u0111\u1eb7t ph\u1ea7n m\u1ec1m th\u00f4ng qua NPM v\u00e0 c\u00e1c tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i kh\u00e1c.<\/p>\n<p>Chu\u1ed7i&nbsp;<code>nginx_pkg<\/code>l\u00e0&nbsp;<em>ID<\/em>&nbsp;cho th\u00e0nh ph\u1ea7n tr\u1ea1ng th\u00e1i,&nbsp;<code>pkg<\/code>l\u00e0 t\u00ean c\u1ee7a&nbsp;<em>m\u00f4-\u0111un<\/em>&nbsp;Salt \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng v\u00e0&nbsp;<code>pkg.installed<\/code>\u0111\u01b0\u1ee3c g\u1ecdi l\u00e0&nbsp;<em>khai b\u00e1o h\u00e0m<\/em>&nbsp;. ID th\u00e0nh ph\u1ea7n l\u00e0 t\u00f9y \u00fd, v\u00ec v\u1eady b\u1ea1n c\u00f3 th\u1ec3 \u0111\u1eb7t t\u00ean theo \u00fd th\u00edch.<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: N\u1ebfu b\u1ea1n \u0111\u1eb7t t\u00ean ID gi\u1ed1ng v\u1edbi g\u00f3i c\u00e0i \u0111\u1eb7t c\u00f3 li\u00ean quan, th\u00ec b\u1ea1n kh\u00f4ng c\u1ea7n ph\u1ea3i ch\u1ec9 \u0111\u1ecbnh t\u00f9y&nbsp;<code>- name<\/code>ch\u1ecdn, v\u00ec n\u00f3 s\u1ebd \u0111\u01b0\u1ee3c suy ra t\u1eeb ID. V\u00ed d\u1ee5, \u0111o\u1ea1n m\u00e3 n\u00e0y c\u0169ng c\u00e0i \u0111\u1eb7t NGINX:<\/p>\n<pre class=\"wp-block-code\"><code>nginx:\n  pkg.installed<\/code><\/pre>\n<p>4.B\u00ean trong th\u01b0&nbsp;<code>hugo<\/code>m\u1ee5c, t\u1ea1o m\u1ed9t t\u1ec7p m\u1edbi&nbsp;<code>service.sls<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>nginx_service:\n  service.running:\n    - name: nginx\n    - enable: True\n    - require:\n      - pkg: nginx_pkg<\/code><\/pre>\n<p>Tr\u1ea1ng th\u00e1i n\u00e0y cho bi\u1ebft&nbsp;<code>nginx<\/code>d\u1ecbch v\u1ee5 ph\u1ea3i \u0111\u01b0\u1ee3c ch\u1ea1y ngay l\u1eadp t\u1ee9c v\u00e0 \u0111\u01b0\u1ee3c b\u1eadt \u0111\u1ec3 ch\u1ea1y khi kh\u1edfi \u0111\u1ed9ng. \u0110\u1ed1i v\u1edbi h\u1ec7 th\u1ed1ng Debian 9, Salt s\u1ebd thi\u1ebft l\u1eadp c\u1ea5u h\u00ecnh&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/what-is-systemd\/\">systemd<\/a>&nbsp;ph\u00f9 h\u1ee3p \u0111\u1ec3 b\u1eadt d\u1ecbch v\u1ee5. Salt c\u0169ng h\u1ed7 tr\u1ee3 c\u00e1c h\u1ec7 th\u1ed1ng init kh\u00e1c.<\/p>\n<p>C\u00e1c d\u00f2ng n\u00e0y&nbsp;<code>require<\/code>ch\u1ec9 r\u00f5 r\u1eb1ng th\u00e0nh ph\u1ea7n tr\u1ea1ng th\u00e1i n\u00e0y kh\u00f4ng \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng cho \u0111\u1ebfn khi&nbsp;<code>nginx_pkg<\/code>th\u00e0nh ph\u1ea7n kia \u0111\u00e3 \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng.<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: Tr\u1eeb khi \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh trong m\u1ed9t&nbsp;<code>require<\/code>tuy\u00ean b\u1ed1, Salt kh\u00f4ng \u0111\u1ea3m b\u1ea3o v\u1ec1 th\u1ee9 t\u1ef1 c\u00e1c th\u00e0nh ph\u1ea7n kh\u00e1c nhau \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng. Th\u1ee9 t\u1ef1 c\u00e1c th\u00e0nh ph\u1ea7n \u0111\u01b0\u1ee3c li\u1ec7t k\u00ea trong t\u1ec7p tr\u1ea1ng th\u00e1i<strong>kh\u00f4ng nh\u1ea5t<\/strong>&nbsp;thi\u1ebft ph\u1ea3i t\u01b0\u01a1ng \u1ee9ng v\u1edbi th\u1ee9 t\u1ef1 ch\u00fang \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng.<\/p>\n<p>6.B\u00ean trong&nbsp;<code>hugo<\/code>th\u01b0 m\u1ee5c, t\u1ea1o m\u1ed9t&nbsp;<code>init.sls<\/code>t\u1ec7p m\u1edbi v\u1edbi n\u1ed9i dung sau:<\/p>\n<pre class=\"wp-block-code\"><code>include:\n  - hugo.install\n  - hugo.service<\/code><\/pre>\n<p>S\u1eed d\u1ee5ng&nbsp;<code>include<\/code>khai b\u00e1o theo c\u00e1ch n\u00e0y ch\u1ec9 \u0111\u01a1n gi\u1ea3n l\u00e0 n\u1ed1i c\u00e1c t\u1ec7p&nbsp;<code>install.sls<\/code>v\u00e0&nbsp;<code>service.sls<\/code>th\u00e0nh m\u1ed9t t\u1ec7p tr\u1ea1ng th\u00e1i k\u1ebft h\u1ee3p duy nh\u1ea5t.<\/p>\n<p>Hi\u1ec7n t\u1ea1i, c\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i n\u00e0y ch\u1ec9 c\u00e0i \u0111\u1eb7t v\u00e0 k\u00edch ho\u1ea1t NGINX. Nhi\u1ec1u ch\u1ee9c n\u0103ng h\u01a1n s\u1ebd \u0111\u01b0\u1ee3c k\u00edch ho\u1ea1t sau trong h\u01b0\u1edbng d\u1eabn n\u00e0y.<\/p>\n<p>C\u00e1c tr\u1ea1ng th\u00e1i&nbsp;<code>install<\/code>and&nbsp;<code>service<\/code>s\u1ebd kh\u00f4ng \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng cho minion ri\u00eang l\u1ebb\u2013thay v\u00e0o \u0111\u00f3, ch\u1ec9 c\u00f3&nbsp;<code>init<\/code>tr\u1ea1ng th\u00e1i k\u1ebft h\u1ee3p m\u1edbi \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng. Trong Salt, khi m\u1ed9t t\u1ec7p c\u00f3 t\u00ean&nbsp;<code>init.sls<\/code>t\u1ed3n t\u1ea1i b\u00ean trong m\u1ed9t th\u01b0 m\u1ee5c, Salt s\u1ebd tham chi\u1ebfu \u0111\u1ebfn tr\u1ea1ng th\u00e1i c\u1ee5 th\u1ec3 \u0111\u00f3 theo t\u00ean c\u1ee7a th\u01b0 m\u1ee5c m\u00e0 n\u00f3 thu\u1ed9c v\u1ec1 (t\u1ee9c l\u00e0&nbsp;<code>hugo<\/code>trong v\u00ed d\u1ee5 c\u1ee7a ch\u00fang t\u00f4i).<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: Vi\u1ec7c t\u1ed5 ch\u1ee9c c\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u1edf \u0111\u00e2y kh\u00f4ng ph\u1ea3i l\u00e0 b\u1eaft bu\u1ed9c c\u1ee7a Salt. Salt kh\u00f4ng \u0111\u1eb7t ra h\u1ea1n ch\u1ebf v\u1ec1 c\u00e1ch b\u1ea1n t\u1ed5 ch\u1ee9c c\u00e1c tr\u1ea1ng th\u00e1i c\u1ee7a m\u00ecnh. C\u1ea5u tr\u00fac c\u1ee5 th\u1ec3 n\u00e0y \u0111\u01b0\u1ee3c tr\u00ecnh b\u00e0y nh\u01b0 m\u1ed9t v\u00ed d\u1ee5 v\u1ec1&nbsp;<a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/best_practices.html\" target=\"_blank\" rel=\"noreferrer noopener\">ph\u01b0\u01a1ng ph\u00e1p hay nh\u1ea5t<\/a>&nbsp;.<\/p>\n<h3 id=\"push-the-salt-formula-to-github\">\u0110\u1ea9y c\u00f4ng th\u1ee9c mu\u1ed1i l\u00ean GitHub<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#push-the-salt-formula-to-github\"><\/a><\/h3>\n<p>1.B\u00ean trong&nbsp;<code>hugo-webserver-salt-formula<\/code>th\u01b0 m\u1ee5c tr\u00ean m\u00e1y t\u00ednh c\u1ee7a b\u1ea1n, h\u00e3y kh\u1edfi t\u1ea1o kho l\u01b0u tr\u1eef Git m\u1edbi:<\/p>\n<pre class=\"wp-block-code\"><code>cd ~\/hugo-webserver-salt-formula\ngit init<\/code><\/pre>\n<p>2.S\u1eafp x\u1ebfp c\u00e1c t\u1eadp tin b\u1ea1n v\u1eeba t\u1ea1o:<\/p>\n<pre class=\"wp-block-code\"><code><code>git add .<\/code><\/code><\/pre>\n<p>3.Xem l\u1ea1i c\u00e1c t\u1eadp tin \u0111\u00e3 d\u00e0n d\u1ef1ng:<\/p>\n<pre class=\"wp-block-code\"><code><code>git status<\/code><\/code><\/pre>\n<pre class=\"wp-block-code\"><code>On branch master\nNo commits yet\nChanges to be committed:\n  (use \"git rm --cached &lt;file&gt;...\" to unstage)\n\n  new file:   hugo\/init.sls\n  new file:   hugo\/install.sls\n  new file:   hugo\/service.sls<\/code><\/pre>\n<p>4.Cam k\u1ebft c\u00e1c t\u1eadp tin:<\/p>\n<pre class=\"wp-block-code\"><code>git commit -m \"Initial commit\"\n<\/code><\/pre>\n<p>5.\u0110\u0103ng nh\u1eadp v\u00e0o trang web GitHub tr\u00ean tr\u00ecnh duy\u1ec7t c\u1ee7a b\u1ea1n v\u00e0 \u0111i\u1ec1u h\u01b0\u1edbng \u0111\u1ebfn trang&nbsp;<a href=\"https:\/\/github.com\/new\" target=\"_blank\" rel=\"noreferrer noopener\">T\u1ea1o kho l\u01b0u tr\u1eef m\u1edbi<\/a>&nbsp;.<\/p>\n<p>6.T\u1ea1o m\u1ed9t kho l\u01b0u tr\u1eef c\u00f4ng khai m\u1edbi v\u1edbi t\u00ean&nbsp;<code>hugo-webserver-salt-formula<\/code>:<\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/github-add-new-repo-salt-formula_huba7218e742ce6270c093cb0a5d7d1c8e_111780_1422x0_resize_q71_bgfafafc_catmullrom_3.jpg\" alt=\"GitHub Kho l\u01b0u tr\u1eef m\u1edbi - Th\u00eam kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c mu\u1ed1i m\u1edbi\">7.Sao ch\u00e9p URL HTTPS cho kho l\u01b0u tr\u1eef m\u1edbi c\u1ee7a b\u1ea1n:<img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/github-new-repo-salt-formula_hu94cc07dc3e97944453cf188aa02f883c_172310_1979x0_resize_q71_bgfafafc_catmullrom_3.jpg\" alt=\"GitHub Kho l\u01b0u tr\u1eef m\u1edbi - Kho l\u01b0u tr\u1eef Salt Formula m\u1edbi\">8.Trong kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c Salt c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n, h\u00e3y th\u00eam kho l\u01b0u tr\u1eef GitHub l\u00e0m kho l\u01b0u tr\u1eef&nbsp;<code>origin<\/code>t\u1eeb xa v\u00e0 \u0111\u1ea9y c\u00e1c t\u1ec7p m\u1edbi c\u1ee7a b\u1ea1n v\u00e0o \u0111\u00f3. Thay th\u1ebf&nbsp;<code>github-username<\/code>b\u1eb1ng ng\u01b0\u1eddi d\u00f9ng GitHub c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>git remote add origin https:\/\/github.com\/github-username\/hugo-webserver-salt-formula.git\ngit push -u origin master<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: N\u1ebfu b\u1ea1n ch\u01b0a t\u1eebng \u0111\u1ea9y b\u1ea5t k\u1ef3 th\u1ee9 g\u00ec kh\u00e1c v\u00e0o t\u00e0i kho\u1ea3n GitHub c\u1ee7a m\u00ecnh t\u1eeb d\u00f2ng l\u1ec7nh tr\u01b0\u1edbc \u0111\u00e2y, b\u1ea1n c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c nh\u1eafc x\u00e1c th\u1ef1c v\u1edbi GitHub. N\u1ebfu b\u1ea1n \u0111\u00e3 b\u1eadt x\u00e1c th\u1ef1c hai y\u1ebfu t\u1ed1 cho t\u00e0i kho\u1ea3n c\u1ee7a m\u00ecnh, b\u1ea1n s\u1ebd c\u1ea7n t\u1ea1o v\u00e0 s\u1eed d\u1ee5ng&nbsp;<a href=\"https:\/\/help.github.com\/articles\/creating-a-personal-access-token-for-the-command-line\/\" target=\"_blank\" rel=\"noreferrer noopener\">m\u00e3 th\u00f4ng b\u00e1o truy c\u1eadp c\u00e1 nh\u00e2n<\/a>&nbsp;.<\/p>\n<p>9.N\u1ebfu b\u1ea1n quay l\u1ea1i&nbsp;<code>hugo-webserver-salt-formula<\/code>kho l\u01b0u tr\u1eef tr\u00ean GitHub v\u00e0 l\u00e0m m\u1edbi trang, b\u00e2y gi\u1edd b\u1ea1n s\u1ebd th\u1ea5y c\u00e1c t\u1ec7p m\u1edbi c\u1ee7a m\u00ecnh.<\/p>\n<h3 id=\"enable-gitfs-on-the-salt-master\">B\u1eadt GitFS tr\u00ean Salt Master<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#enable-gitfs-on-the-salt-master\"><\/a><\/h3>\n<p>C\u1eadp nh\u1eadt Salt master c\u1ee7a b\u1ea1n \u0111\u1ec3 ph\u1ee5c v\u1ee5 c\u00f4ng th\u1ee9c m\u1edbi t\u1eeb GitHub:<\/p>\n<p>1.Salt y\u00eau c\u1ea7u b\u1ea1n ph\u1ea3i c\u00e0i \u0111\u1eb7t giao di\u1ec7n Python v\u00e0o Git \u0111\u1ec3 s\u1eed d\u1ee5ng GitFS. Tr\u00ean Salt master Linode:<code> <\/code><\/p>\n<pre class=\"wp-block-code\"><code><code>sudo apt-get install python-git<\/code><\/code><\/pre>\n<p>2.M\u1edf&nbsp;<code>\/etc\/salt\/master<\/code>trong tr\u00ecnh so\u1ea1n th\u1ea3o v\u0103n b\u1ea3n. B\u1ecf ch\u00fa th\u00edch cho&nbsp;<code>fileserver_backend<\/code>ph\u1ea7n khai b\u00e1o v\u00e0 nh\u1eadp&nbsp;<code>roots<\/code>v\u00e0&nbsp;<code>gitfs<\/code>v\u00e0o danh s\u00e1ch khai b\u00e1o:<\/p>\n<pre class=\"wp-block-code\"><code>fileserver_backend:\n  - roots\n  - gitfs<\/code><\/pre>\n<p><code>roots<\/code>\u0111\u1ec1 c\u1eadp \u0111\u1ebfn c\u00e1c t\u1ec7p Salt \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef tr\u00ean h\u1ec7 th\u1ed1ng t\u1ec7p c\u1ee7a m\u00e1y ch\u1ee7 ch\u00ednh. Trong khi c\u00f4ng th\u1ee9c Salt c\u1ee7a m\u00e1y ch\u1ee7 web Hugo \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef tr\u00ean GitHub,&nbsp;<a href=\"https:\/\/docs.saltproject.io\/en\/latest\/ref\/states\/top.html#states-top\" target=\"_blank\" rel=\"noreferrer noopener\"><em>t\u1ec7p Salt Top<\/em><\/a>&nbsp;s\u1ebd \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef tr\u00ean m\u00e1y ch\u1ee7 ch\u00ednh. T\u1ec7p Top l\u00e0 c\u00e1ch Salt \u00e1nh x\u1ea1 c\u00e1c tr\u1ea1ng th\u00e1i \u0111\u1ebfn c\u00e1c minion m\u00e0 ch\u00fang s\u1ebd \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng.<\/p>\n<p>3.Trong c\u00f9ng m\u1ed9t t\u1ec7p, b\u1ecf ch\u00fa th\u00edch \u1edf ph\u1ea7n&nbsp;<code>gitfs_remotes<\/code>khai b\u00e1o v\u00e0 nh\u1eadp URL kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c Salt c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>gitfs_remotes:\n  - https:\/\/github.com\/your_github_user\/hugo-webserver-salt-formula.git<\/code><\/pre>\n<p>4.B\u1ecf ch\u00fa th\u00edch cho&nbsp;<code>gitfs_provider<\/code>ph\u1ea7n khai b\u00e1o v\u00e0 \u0111\u1eb7t gi\u00e1 tr\u1ecb c\u1ee7a n\u00f3 th\u00e0nh&nbsp;<code>gitpython<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>gitfs_provider: gitpython<\/code><\/pre>\n<h3 id=\"apply-the-formulas-state-to-the-minion\">\u00c1p d\u1ee5ng tr\u1ea1ng th\u00e1i c\u1ee7a c\u00f4ng th\u1ee9c cho Minion<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#apply-the-formulas-state-to-the-minion\"><\/a><\/h3>\n<p>1.Trong&nbsp;<code>\/etc\/salt\/master<\/code>, b\u1ecf ch\u00fa th\u00edch \u1edf ph\u1ea7n&nbsp;<code>file_roots<\/code>khai b\u00e1o v\u00e0 \u0111\u1eb7t c\u00e1c gi\u00e1 tr\u1ecb sau:<\/p>\n<pre class=\"wp-block-code\"><code>file_roots:\n  base:\n    - \/srv\/salt\/<\/code><\/pre>\n<p><code>file_roots<\/code>ch\u1ec9 r\u00f5 n\u01a1i l\u01b0u tr\u1eef c\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i tr\u00ean h\u1ec7 th\u1ed1ng t\u1ec7p c\u1ee7a Master. \u0110i\u1ec1u n\u00e0y \u0111\u01b0\u1ee3c tham chi\u1ebfu khi&nbsp;<code>- roots<\/code>\u0111\u01b0\u1ee3c khai b\u00e1o trong&nbsp;<code>fileserver_backend<\/code>ph\u1ea7n. tham chi\u1ebfu \u0111\u1ebfn&nbsp;<em>m\u00f4i tr\u01b0\u1eddng<\/em><code>base<\/code>&nbsp;Salt&nbsp;, l\u00e0 c\u00e2y c\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i c\u00f3 th\u1ec3 \u00e1p d\u1ee5ng cho minion. H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1ebd ch\u1ec9 s\u1eed d\u1ee5ng m\u00f4i&nbsp;tr\u01b0\u1eddng, nh\u01b0ng c\u00f3 th\u1ec3 t\u1ea1o c\u00e1c m\u00f4i tr\u01b0\u1eddng kh\u00e1c cho m\u1ee5c \u0111\u00edch ph\u00e1t tri\u1ec3n, QA, v.v.<code>base<\/code><\/p>\n<p>2.Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Salt tr\u00ean m\u00e1y ch\u1ee7 ch\u00ednh \u0111\u1ec3 k\u00edch ho\u1ea1t c\u00e1c thay \u0111\u1ed5i trong&nbsp;<code>\/etc\/salt\/master<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>sudo systemctl restart salt-master<\/code><\/pre>\n<p>3.T\u1ea1o&nbsp;<code>\/srv\/salt<\/code>th\u01b0 m\u1ee5c tr\u00ean m\u00e1y ch\u1ee7 Salt:<\/p>\n<pre class=\"wp-block-code\"><code>sudo mkdir \/srv\/salt\n<\/code><\/pre>\n<pre class=\"wp-block-preformatted\">4.T\u1ea1o m\u1ed9t t\u1eadp tin m\u1edbi top.slstrong \/srv\/salt:<\/pre>\n<pre class=\"wp-block-code\"><code>base:\n  'hugo-webserver':\n    - hugo<\/code><\/pre>\n<p>\u0110\u00e2y l\u00e0 t\u1ec7p Top c\u1ee7a Salt v\u00e0 \u0111o\u1ea1n m\u00e3 n\u00e0y tuy\u00ean b\u1ed1 r\u1eb1ng&nbsp;<code>hugo-webserver<\/code>minion s\u1ebd nh\u1eadn&nbsp;<code>init.sls<\/code>tr\u1ea1ng th\u00e1i t\u1eeb&nbsp;<code>hugo<\/code>th\u01b0 m\u1ee5c (t\u1eeb c\u00f4ng th\u1ee9c Salt do GitHub l\u01b0u tr\u1eef c\u1ee7a b\u1ea1n).<\/p>\n<p>5.Y\u00eau c\u1ea7u Salt \u00e1p d\u1ee5ng tr\u1ea1ng th\u00e1i t\u1eeb t\u1ec7p Top v\u00e0o minion:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt 'hugo-webserver' state.apply\n<\/code><\/pre>\n<p>Salt as tham chi\u1ebfu l\u1ec7nh n\u00e0y nh\u01b0 m\u1ed9t&nbsp;<em>highstate<\/em>&nbsp;. Ch\u1ea1y highstate c\u00f3 th\u1ec3 m\u1ea5t m\u1ed9t ch\u00fat th\u1eddi gian \u0111\u1ec3 ho\u00e0n t\u1ea5t v\u00e0 \u0111\u1ea7u ra c\u1ee7a l\u1ec7nh s\u1ebd m\u00f4 t\u1ea3 nh\u1eefng h\u00e0nh \u0111\u1ed9ng n\u00e0o \u0111\u00e3 \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n tr\u00ean minion. \u0110\u1ea7u ra c\u0169ng s\u1ebd hi\u1ec3n th\u1ecb n\u1ebfu b\u1ea5t k\u1ef3 h\u00e0nh \u0111\u1ed9ng n\u00e0o kh\u00f4ng th\u00e0nh c\u00f4ng.<\/p>\n<p>6.N\u1ebfu b\u1ea1n truy c\u1eadp t\u00ean mi\u1ec1n c\u1ee7a m\u00ecnh tr\u00ean tr\u00ecnh duy\u1ec7t web, b\u00e2y gi\u1edd b\u1ea1n s\u1ebd th\u1ea5y trang th\u1eed nghi\u1ec7m m\u1eb7c \u0111\u1ecbnh c\u1ee7a NGINX do Salt minion cung c\u1ea5p.<\/p>\n<h2 id=\"initialize-the-hugo-site\">Kh\u1edfi t\u1ea1o trang Hugo<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#initialize-the-hugo-site\"><\/a><\/h2>\n<p>1.Tr\u00ean m\u00e1y t\u00ednh c\u1ee7a b\u1ea1n, h\u00e3y t\u1ea1o m\u1ed9t trang Hugo m\u1edbi. \u0110\u1ea3m b\u1ea3o r\u1eb1ng b\u1ea1n kh\u00f4ng ch\u1ea1y l\u1ec7nh n\u00e0y trong&nbsp;<code>hugo-webserver-salt-formula<\/code>th\u01b0 m\u1ee5c c\u1ee7a m\u00ecnh:<\/p>\n<pre class=\"wp-block-code\"><code>hugo new site example-hugo-site\n<\/code><\/pre>\n<p>2.\u0110i\u1ec1u h\u01b0\u1edbng \u0111\u1ebfn th\u01b0 m\u1ee5c trang web Hugo m\u1edbi v\u00e0 kh\u1edfi t\u1ea1o kho l\u01b0u tr\u1eef Git:<\/p>\n<pre class=\"wp-block-code\"><code>cd example-hugo-site\ngit init<\/code><\/pre>\n<p>3.C\u00e0i \u0111\u1eb7t m\u1ed9t ch\u1ee7 \u0111\u1ec1 v\u00e0o&nbsp;<code>themes\/<\/code>th\u01b0 m\u1ee5c. H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1eed d\u1ee5ng&nbsp;<a href=\"https:\/\/themes.gohugo.io\/cactus\/\" target=\"_blank\" rel=\"noreferrer noopener\">ch\u1ee7 \u0111\u1ec1 Cactus<\/a>&nbsp;:<\/p>\n<pre class=\"wp-block-code\"><code>git submodule add https:\/\/github.com\/digitalcraftsman\/hugo-cactus-theme.git themes\/hugo-cactus-theme\n<\/code><\/pre>\n<p>4.Ch\u1ee7 \u0111\u1ec1 \u0111i k\u00e8m v\u1edbi m\u1ed9t s\u1ed1 n\u1ed9i dung v\u00ed d\u1ee5. Sao ch\u00e9p n\u00f3 v\u00e0o g\u1ed1c trang web c\u1ee7a b\u1ea1n \u0111\u1ec3 c\u00f3 th\u1ec3 xem:<\/p>\n<pre class=\"wp-block-code\"><code>cp -r themes\/hugo-cactus-theme\/exampleSite\/ .\n<\/code><\/pre>\n<p>5.Ch\u1ec9nh s\u1eeda&nbsp;c\u00e1c t\u00f9y ch\u1ecdn&nbsp;<code>baseurl<\/code>,&nbsp;<code>themesDir<\/code>, v\u00e0&nbsp;nh\u01b0 sau; thay th\u1ebf&nbsp;b\u1eb1ng t\u00ean mi\u1ec1n v\u00e0&nbsp;t\u00ean c\u1ee7a ri\u00eang b\u1ea1n:<code>nameconfig.tomlexample.comYour Name<\/code><\/p>\n<pre class=\"wp-block-code\"><code># &#91;...]\nbaseURL = \"http:\/\/example.com\"\n# &#91;...]\nthemesDir = \"themes\"\n# &#91;...]\n  name = \"Your Name\"<\/code><\/pre>\n<p>6.Ch\u1ea1y m\u00e1y ch\u1ee7 ph\u00e1t tri\u1ec3n Hugo tr\u00ean m\u00e1y t\u00ednh c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>hugo server<\/code><\/pre>\n<p>\u0110\u1ea7u ra c\u1ee7a l\u1ec7nh n\u00e0y s\u1ebd k\u1ebft th\u00fac b\u1eb1ng m\u1ed9t d\u00f2ng nh\u01b0 sau:<\/p>\n<pre class=\"wp-block-code\"><code>Web Server is available at http:\/\/localhost:1313\/ (bind address 127.0.0.1)\n<\/code><\/pre>\n<p>7.N\u1ebfu b\u1ea1n xem URL t\u1eeb \u0111\u1ea7u ra n\u00e0y trong tr\u00ecnh duy\u1ec7t, b\u1ea1n c\u00f3 th\u1ec3 th\u1ea5y trang Hugo m\u1edbi c\u1ee7a m\u00ecnh:<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/hugo-dev-server-browser_hu05da2cc5b98313d0b19ffbe44d0eac99_50290_1588x0_resize_q71_bgfafafc_catmullrom_3.jpg\" alt=\"New Hugo Site - Development Server\" title=\"New Hugo Site - Development Server\"\/><\/figure>\n<p>8.Nh\u1eadp&nbsp;<strong>CTRL-C<\/strong>&nbsp;v\u00e0o phi\u00ean terminal tr\u00ean m\u00e1y t\u00ednh c\u1ee7a b\u1ea1n \u0111\u1ec3 d\u1eebng m\u00e1y ch\u1ee7 ph\u00e1t tri\u1ec3n Hugo. M\u1edf t\u1ec7p&nbsp;<code>.gitignore<\/code>v\u00e0 \u0111\u1ea3m b\u1ea3o&nbsp;<code>public\/<\/code>\u0111\u01b0\u1ee3c li\u1ec7t k\u00ea. M\u1eb7c \u0111\u1ecbnh&nbsp;<code>.gitignore<\/code>t\u1eeb ch\u1ee7 \u0111\u1ec1 Cactus s\u1ebd tr\u00f4ng nh\u01b0 sau:<\/p>\n<pre class=\"wp-block-code\"><code>public\/\nthemes<\/code><\/pre>\n<p>Th\u01b0&nbsp;<code>public<\/code>m\u1ee5c l\u00e0 k\u1ebft qu\u1ea3 c\u1ee7a vi\u1ec7c Hugo bi\u00ean d\u1ecbch c\u00e1c t\u1ec7p n\u1ed9i dung Markdown th\u00e0nh HTML. Nh\u1eefng t\u1ec7p n\u00e0y c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c t\u1ea1o l\u1ea1i b\u1edfi b\u1ea5t k\u1ef3 ai t\u1ea3i xu\u1ed1ng m\u00e3 trang web c\u1ee7a b\u1ea1n, v\u00ec v\u1eady ch\u00fang s\u1ebd kh\u00f4ng \u0111\u01b0\u1ee3c ki\u1ec3m tra trong ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n.<\/p>\n<h3 id=\"push-the-hugo-site-to-github\">\u0110\u1ea9y trang Hugo l\u00ean GitHub<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#push-the-hugo-site-to-github\"><\/a><\/h3>\n<p>1.Trong th\u01b0 m\u1ee5c site Hugo, h\u00e3y x\u00e1c nh\u1eadn c\u00e1c t\u1ec7p site m\u1edbi:<\/p>\n<pre class=\"wp-block-code\"><code>git add .\ngit commit -m \"Initial commit\"<\/code><\/pre>\n<p>2.T\u1ea1o m\u1ed9t kho l\u01b0u tr\u1eef c\u00f4ng khai m\u1edbi tr\u00ean GitHub c\u00f3 t\u00ean l\u00e0&nbsp;<code>example-hugo-site<\/code>v\u00e0 sao ch\u00e9p URL HTTPS c\u1ee7a kho l\u01b0u tr\u1eef.<\/p>\n<p>3.Trong th\u01b0 m\u1ee5c trang web, th\u00eam kho l\u01b0u tr\u1eef GitHub l\u00e0m kho l\u01b0u&nbsp;<code>origin<\/code>tr\u1eef t\u1eeb xa v\u00e0 \u0111\u1ea9y c\u00e1c t\u1ec7p m\u1edbi c\u1ee7a b\u1ea1n v\u00e0o \u0111\u00f3; thay th\u1ebf&nbsp;<code>github-username<\/code>b\u1eb1ng ng\u01b0\u1eddi d\u00f9ng GitHub c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>git remote add origin https:\/\/github.com\/github-username\/example-hugo-site.git\ngit push -u origin master\n<\/code><\/pre>\n<h2 id=\"deploy-the-hugo-site\">Tri\u1ec3n khai trang Hugo<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#deploy-the-hugo-site\"><\/a><\/h2>\n<p>C\u00f4ng th\u1ee9c c\u1ee7a Salt minion c\u1ea7n \u0111\u01b0\u1ee3c c\u1eadp nh\u1eadt \u0111\u1ec3 ph\u1ee5c v\u1ee5 cho trang Hugo. C\u1ee5 th\u1ec3, c\u00f4ng th\u1ee9c s\u1ebd c\u1ea7n c\u00f3 c\u00e1c tr\u1ea1ng th\u00e1i sau:<\/p>\n<ul>\n<li>C\u00e0i \u0111\u1eb7t Git v\u00e0 sao ch\u00e9p kho l\u01b0u tr\u1eef trang web Hugo t\u1eeb GitHub.<\/li>\n<li>C\u00e0i \u0111\u1eb7t Hugo v\u00e0 x\u00e2y d\u1ef1ng c\u00e1c t\u1ec7p HTML t\u1eeb n\u1ed9i dung Markdown.<\/li>\n<li>C\u1eadp nh\u1eadt c\u1ea5u h\u00ecnh NGINX \u0111\u1ec3 ph\u1ee5c v\u1ee5 cho trang web \u0111\u00e3 x\u00e2y d\u1ef1ng.<\/li>\n<\/ul>\n<p>M\u1ed9t s\u1ed1 th\u00e0nh ph\u1ea7n tr\u1ea1ng th\u00e1i m\u1edbi s\u1ebd tham chi\u1ebfu \u0111\u1ebfn d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong&nbsp;<a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/pillar\/\" target=\"_blank\" rel=\"noreferrer noopener\"><em>Salt Pillar<\/em><\/a>&nbsp;. Pillar l\u00e0 h\u1ec7 th\u1ed1ng Salt l\u01b0u tr\u1eef d\u1eef li\u1ec7u ri\u00eang t\u01b0 v\u00e0 c\u00e1c tham s\u1ed1 kh\u00e1c m\u00e0 b\u1ea1n kh\u00f4ng mu\u1ed1n li\u1ec7t k\u00ea trong c\u00f4ng th\u1ee9c c\u1ee7a m\u00ecnh. D\u1eef li\u1ec7u Pillar s\u1ebd \u0111\u01b0\u1ee3c l\u01b0u d\u01b0\u1edbi d\u1ea1ng t\u1ec7p tr\u00ean Salt master v\u00e0 kh\u00f4ng \u0111\u01b0\u1ee3c ki\u1ec3m tra trong ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n.<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: C\u00f3 nh\u1eefng ph\u01b0\u01a1ng ph\u00e1p \u0111\u1ec3 ki\u1ec3m tra d\u1eef li\u1ec7u n\u00e0y m\u1ed9t c\u00e1ch an to\u00e0n v\u00e0o ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n ho\u1eb7c s\u1eed d\u1ee5ng c\u00e1c ch\u01b0\u01a1ng tr\u00ecnh ph\u1ee5 tr\u1ee3 kh\u00e1c \u0111\u1ec3 l\u01b0u tr\u1eef d\u1eef li\u1ec7u, nh\u01b0ng nh\u1eefng chi\u1ebfn l\u01b0\u1ee3c \u0111\u00f3 n\u1eb1m ngo\u00e0i ph\u1ea1m vi c\u1ee7a h\u01b0\u1edbng d\u1eabn n\u00e0y.<\/p>\n<p>D\u1eef li\u1ec7u tr\u1ee5 c\u1ed9t \u0111\u01b0\u1ee3c \u0111\u01b0a v\u00e0o c\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i v\u1edbi t\u00ednh n\u0103ng&nbsp;<a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/jinja\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">t\u1ea1o m\u1eabu&nbsp;<\/a><a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/jinja\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\"><em>Jinja<\/em><\/a>&nbsp;c\u1ee7a Salt . C\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i \u0111\u1ea7u ti\u00ean \u0111\u01b0\u1ee3c \u0111\u00e1nh gi\u00e1 d\u01b0\u1edbi d\u1ea1ng m\u1eabu Jinja v\u00e0 sau \u0111\u00f3 l\u00e0 YAML.<\/p>\n<h3 id=\"install-git-and-hugo\">C\u00e0i \u0111\u1eb7t Git v\u00e0 Hugo<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#install-git-and-hugo\"><\/a><\/h3>\n<p>Trong kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c Salt c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n, h\u00e3y ch\u1ec9nh s\u1eeda&nbsp;<code>install.sls<\/code>t\u1ec7p \u0111\u1ec3 th\u00eam&nbsp;<code>git_pkg<\/code>v\u00e0&nbsp;<code>hugo_pkg<\/code>c\u00e1c tr\u1ea1ng th\u00e1i:<\/p>\n<pre class=\"wp-block-code\"><code># &#91;...]\n\ngit_pkg:\n  pkg.installed:\n    - name: git\n\nhugo_pkg:\n  pkg.installed:\n    - name: hugo\n    - sources:\n      - hugo: https:\/\/github.com\/gohugoio\/hugo\/releases\/download\/v{{ pillar&#91;'hugo_deployment_data']&#91;'hugo_version'] }}\/hugo_{{ pillar&#91;'hugo_deployment_data']&#91;'hugo_version'] }}_Linux-64bit.deb<\/code><\/pre>\n<p>Th\u00e0nh ph\u1ea7n tr\u1ea1ng th\u00e1i \u0111\u1ea7u ti\u00ean c\u00e0i \u0111\u1eb7t Git v\u00e0 th\u00e0nh ph\u1ea7n th\u1ee9 hai c\u00e0i \u0111\u1eb7t Hugo.&nbsp;<code>sources<\/code>Khai b\u00e1o c\u1ee7a th\u00e0nh ph\u1ea7n th\u1ee9 hai ch\u1ec9 \u0111\u1ecbnh r\u1eb1ng g\u00f3i ph\u1ea3i \u0111\u01b0\u1ee3c t\u1ea3i xu\u1ed1ng t\u1eeb kho l\u01b0u tr\u1eef GitHub c\u1ee7a Hugo (thay v\u00ec t\u1eeb tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i ph\u00e2n ph\u1ed1i).<\/p>\n<p>C\u00fa&nbsp;<code>{{ }}<\/code>ph\u00e1p xu\u1ea5t hi\u1ec7n trong&nbsp;<code>{{ pillar['hugo_deployment_data']['hugo_version'] }}<\/code>l\u00e0 c\u00e2u l\u1ec7nh thay th\u1ebf Jinja.&nbsp;<code>pillar['hugo_deployment_data']['hugo_version']<\/code>tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb c\u1ee7a&nbsp;<code>hugo_version<\/code>kh\u00f3a t\u1eeb m\u1ed9t t\u1eeb \u0111i\u1ec3n c\u00f3 t\u00ean&nbsp;<code>hugo_deployment_data<\/code>trong Pillar. Gi\u1eef phi\u00ean b\u1ea3n Hugo trong Pillar cho ph\u00e9p b\u1ea1n c\u1eadp nh\u1eadt Hugo m\u00e0 kh\u00f4ng c\u1ea7n c\u1eadp nh\u1eadt c\u00f4ng th\u1ee9c c\u1ee7a m\u00ecnh.<\/p>\n<h3 id=\"clone-the-hugo-site-git-repository\">Sao ch\u00e9p kho l\u01b0u tr\u1eef Git c\u1ee7a Hugo Site<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#clone-the-hugo-site-git-repository\"><\/a><\/h3>\n<p>T\u1ea1o m\u1ed9t&nbsp;<code>config.sls<\/code>t\u1ec7p m\u1edbi trong&nbsp;<code>hugo<\/code>th\u01b0 m\u1ee5c kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c Salt c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>hugo_group:\n  group.present:\n    - name: {{ pillar&#91;'hugo_deployment_data']&#91;'group'] }}\n\nhugo_user:\n  user.present:\n    - name: {{ pillar&#91;'hugo_deployment_data']&#91;'user'] }}\n    - gid: {{ pillar&#91;'hugo_deployment_data']&#91;'group'] }}\n    - home: {{ pillar&#91;'hugo_deployment_data']&#91;'home_dir'] }}\n    - createhome: True\n    - require:\n      - group: hugo_group\n\nhugo_site_repo:\n  cmd.run:\n    - name: git clone --recurse-submodules https:\/\/github.com\/{{ pillar&#91;'hugo_deployment_data']&#91;'github_account'] }}\/{{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}.git\n    - cwd: {{ pillar&#91;'hugo_deployment_data']&#91;'home_dir'] }}\n    - runas: {{ pillar&#91;'hugo_deployment_data']&#91;'user'] }}\n    - creates: {{ pillar&#91;'hugo_deployment_data']&#91;'home_dir'] }}\/{{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}\n    - require:\n      - pkg: git_pkg\n      - user: hugo_user<\/code><\/pre>\n<p>Th\u00e0nh ph\u1ea7n cu\u1ed1i c\u00f9ng&nbsp;<code>hugo_site_repo<\/code>trong \u0111o\u1ea1n m\u00e3 n\u00e0y ch\u1ecbu tr\u00e1ch nhi\u1ec7m sao ch\u00e9p kho l\u01b0u tr\u1eef trang Hugo m\u1eabu t\u1eeb GitHub. Kho l\u01b0u tr\u1eef \u0111\u01b0\u1ee3c sao ch\u00e9p n\u00e0y \u0111\u01b0\u1ee3c \u0111\u1eb7t trong th\u01b0 m\u1ee5c g\u1ed1c c\u1ee7a ng\u01b0\u1eddi d\u00f9ng h\u1ec7 th\u1ed1ng m\u00e0 Salt t\u1ea1o ra trong c\u00e1c th\u00e0nh ph\u1ea7n tr\u01b0\u1edbc \u0111\u00f3. L\u1ec7nh sao ch\u00e9p c\u0169ng t\u1ea3i xu\u1ed1ng \u0111\u1ec7 quy m\u00f4-\u0111un ph\u1ee5 ch\u1ee7 \u0111\u1ec1 Cactus.<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: Tuy\u00ean&nbsp;<code>- creates<\/code>b\u1ed1 cho Salt bi\u1ebft r\u1eb1ng ch\u1ea1y&nbsp;<code>cmd<\/code>m\u00f4-\u0111un l\u1ec7nh s\u1ebd d\u1eabn \u0111\u1ebfn vi\u1ec7c t\u1ea1o t\u1ec7p \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. N\u1ebfu tr\u1ea1ng th\u00e1i \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng l\u1ea1i sau \u0111\u00f3, Salt s\u1ebd ki\u1ec3m tra xem t\u1ec7p \u0111\u00f3 \u0111\u00e3 t\u1ed3n t\u1ea1i ch\u01b0a. N\u1ebfu t\u1ed3n t\u1ea1i, Salt s\u1ebd&nbsp;<em>kh\u00f4ng<\/em>&nbsp;ch\u1ea1y l\u1ea1i m\u00f4-\u0111un.<\/p>\n<p>C\u00e1c&nbsp;<code>require<\/code>khai b\u00e1o trong m\u1ed7i th\u00e0nh ph\u1ea7n \u0111\u1ea3m b\u1ea3o r\u1eb1ng:<\/p>\n<ul>\n<li>B\u1ea3n sao s\u1ebd kh\u00f4ng \u0111\u01b0\u1ee3c ch\u1ea1y cho \u0111\u1ebfn khi ng\u01b0\u1eddi d\u00f9ng h\u1ec7 th\u1ed1ng v\u00e0 th\u01b0 m\u1ee5c ch\u00ednh \u0111\u01b0\u1ee3c t\u1ea1o v\u00e0 cho \u0111\u1ebfn khi g\u00f3i ph\u1ea7n m\u1ec1m Git \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t.<\/li>\n<li>Ng\u01b0\u1eddi d\u00f9ng s\u1ebd kh\u00f4ng \u0111\u01b0\u1ee3c t\u1ea1o cho \u0111\u1ebfn khi nh\u00f3m m\u00e0 ng\u01b0\u1eddi d\u00f9ng \u0111\u00f3 thu\u1ed9c v\u1ec1 \u0111\u01b0\u1ee3c t\u1ea1o.<\/li>\n<\/ul>\n<p>Thay v\u00ec m\u00e3 h\u00f3a c\u1ee9ng c\u00e1c tham s\u1ed1 cho ng\u01b0\u1eddi d\u00f9ng, nh\u00f3m, th\u01b0 m\u1ee5c ch\u00ednh, t\u00e0i kho\u1ea3n GitHub v\u00e0 t\u00ean kho l\u01b0u tr\u1eef, nh\u1eefng th\u00f4ng tin n\u00e0y s\u1ebd \u0111\u01b0\u1ee3c l\u1ea5y t\u1eeb Pillar.<\/p>\n<h3 id=\"configure-nginx\">C\u1ea5u h\u00ecnh NGINX<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#configure-nginx\"><\/a><\/h3>\n<p>1.Th\u00eam c\u00e1c tr\u1ea1ng th\u00e1i sau v\u00e0o&nbsp;<code>config.sls<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>nginx_default:\n  file.absent:\n    - name: '\/etc\/nginx\/sites-enabled\/default'\n    - require:\n      - pkg: nginx_pkg\n\nnginx_config:\n  file.managed:\n    - name: \/etc\/nginx\/sites-available\/hugo_site\n    - source: salt:\/\/hugo\/files\/hugo_site\n    - user: root\n    - group: root\n    - mode: 0644\n    - template: jinja\n    - require:\n      - pkg: nginx_pkg\n\nnginx_symlink:\n  file.symlink:\n    - name: \/etc\/nginx\/sites-enabled\/hugo_site\n    - target: \/etc\/nginx\/sites-available\/hugo_site\n    - user: root\n    - group: root\n    - require:\n      - file: nginx_config\n\nnginx_document_root:\n  file.directory:\n    - name: {{ pillar&#91;'hugo_deployment_data']&#91;'nginx_document_root'] }}\/{{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}\n    - user: {{ pillar&#91;'hugo_deployment_data']&#91;'user'] }}\n    - group: {{ pillar&#91;'hugo_deployment_data']&#91;'group'] }}\n    - dir_mode: 0755\n    - require:\n      - user: hugo_user<\/code><\/pre>\n<ul>\n<li>Th\u00e0nh ph\u1ea7n n\u00e0y&nbsp;<code>nginx_default<\/code>x\u00f3a li\u00ean k\u1ebft t\u01b0\u1ee3ng tr\u01b0ng&nbsp;<code>sites-enabled<\/code>cho c\u1ea5u h\u00ecnh NGINX m\u1eb7c \u0111\u1ecbnh, v\u00f4 hi\u1ec7u h\u00f3a c\u1ea5u h\u00ecnh \u0111\u00f3.<\/li>\n<li><code>nginx_config<\/code>v\u00e0&nbsp;<code>nginx_symlink<\/code>sau \u0111\u00f3 t\u1ea1o m\u1ed9t t\u1ec7p c\u1ea5u h\u00ecnh m\u1edbi trong&nbsp;<code>sites-available<\/code>v\u00e0 m\u1ed9t li\u00ean k\u1ebft t\u01b0\u1ee3ng tr\u01b0ng \u0111\u1ebfn t\u1ec7p \u0111\u00f3 trong&nbsp;<code>sites-enabled<\/code>.<\/li>\n<li>Th\u00e0nh ph\u1ea7n n\u00e0y&nbsp;<code>nginx_document_root<\/code>t\u1ea1o th\u01b0 m\u1ee5c m\u00e0 NGINX s\u1ebd d\u00f9ng \u0111\u1ec3 l\u01b0u tr\u1eef c\u00e1c t\u1ec7p trang Hugo c\u1ee7a b\u1ea1n (khi \u0111i\u1ec1n d\u1eef li\u1ec7u Pillar, th\u01b0 m\u1ee5c n\u00e0y s\u1ebd tr\u00f4ng nh\u01b0 th\u1ebf n\u00e0y&nbsp;<code>\/var\/www\/example-hugo-site<\/code>).<\/li>\n<\/ul>\n<p>2.Tuy\u00ean&nbsp;<code>- source: salt:\/\/hugo\/files\/hugo_site<\/code>b\u1ed1 trong&nbsp;<code>nginx_config<\/code>tham chi\u1ebfu \u0111\u1ebfn t\u1ec7p c\u1ea5u h\u00ecnh NGINX hi\u1ec7n ch\u01b0a c\u00f3 trong kho l\u01b0u tr\u1eef c\u1ee7a b\u1ea1n. T\u1ea1o th\u01b0&nbsp;<code>files\/<\/code>m\u1ee5c:<\/p>\n<pre class=\"wp-block-code\"><code>cd ~\/hugo-webserver-salt-formula\/hugo\nmkdir files<\/code><\/pre>\n<p>3.T\u1ea1o&nbsp;<code>hugo_site<\/code>t\u1eadp tin b\u00ean trong&nbsp;<code>files\/<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>server {\n    listen 80;\n    listen &#91;::]:80;\n    server_name {{ pillar&#91;'hugo_deployment_data']&#91;'domain_name'] }};\n\n    root {{ pillar&#91;'hugo_deployment_data']&#91;'nginx_document_root'] }}\/{{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }};\n\n    index index.html index.htm index.nginx-debian.html;\n\n    location \/ {\n        try_files $uri $uri\/ = \/404.html;\n    }\n}<\/code><\/pre>\n<p>Th\u00e0nh&nbsp;<code>nginx_config<\/code>ph\u1ea7n qu\u1ea3n l\u00fd t\u1ec7p n\u00e0y c\u0169ng li\u1ec7t k\u00ea&nbsp;<code>- template: jinja<\/code>khai b\u00e1o, do \u0111\u00f3 t\u1ec7p ngu\u1ed3n \u0111\u01b0\u1ee3c di\u1ec5n gi\u1ea3i l\u00e0 m\u1eabu Jinja. T\u1ec7p ngu\u1ed3n c\u00f3 th\u1ec3 thay th\u1ebf c\u00e1c gi\u00e1 tr\u1ecb t\u1eeb Pillar b\u1eb1ng c\u00fa ph\u00e1p thay th\u1ebf Jinja.<\/p>\n<p>4.<strong>Thay th\u1ebf<\/strong>&nbsp;n\u1ed9i dung c\u1ee7a b\u1ea1n&nbsp;<code>service.sls<\/code>b\u1eb1ng \u0111o\u1ea1n tr\u00edch n\u00e0y:<\/p>\n<pre class=\"wp-block-code\"><code>nginx_service:\n  service.running:\n    - name: nginx\n    - enable: True\n    - require:\n      - file: nginx_symlink\n    - watch:\n      - file: nginx_config<\/code><\/pre>\n<p>Th\u00e0nh ph\u1ea7n n\u00e0y&nbsp;<code>nginx_service<\/code>hi\u1ec7n y\u00eau c\u1ea7u&nbsp;<code>nginx_symlink<\/code>thay v\u00ec&nbsp;<code>nginx_pkg<\/code>. N\u1ebfu kh\u00f4ng c\u00f3 thay \u0111\u1ed5i n\u00e0y, d\u1ecbch v\u1ee5 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c b\u1eadt v\u00e0 ch\u1ea1y tr\u01b0\u1edbc khi c\u1ea5u h\u00ecnh NGINX m\u1edbi \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp.&nbsp;<code>- watch<\/code>Tuy\u00ean b\u1ed1 n\u00e0y c\u0169ng h\u01b0\u1edbng d\u1eabn NGINX kh\u1edfi \u0111\u1ed9ng l\u1ea1i b\u1ea5t c\u1ee9 khi n\u00e0o c\u00f3 thay \u0111\u1ed5i \u0111\u01b0\u1ee3c&nbsp;<code>nginx_config<\/code>th\u1ef1c hi\u1ec7n.<\/p>\n<h3 id=\"build-hugo\">X\u00e2y d\u1ef1ng Hugo<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#build-hugo\"><\/a><\/h3>\n<p>1.Th\u00eam&nbsp;<code>build_script<\/code>tr\u1ea1ng th\u00e1i v\u00e0o&nbsp;<code>config.sls<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>build_script:\n  file.managed:\n    - name: {{ pillar&#91;'hugo_deployment_data']&#91;'home_dir'] }}\/deploy.sh\n    - source: salt:\/\/hugo\/files\/deploy.sh\n    - user: {{ pillar&#91;'hugo_deployment_data']&#91;'user'] }}\n    - group: {{ pillar&#91;'hugo_deployment_data']&#91;'group'] }}\n    - mode: 0755\n    - template: jinja\n    - require:\n      - user: hugo_user\n  cmd.run:\n    - name: .\/deploy.sh\n    - cwd: {{ pillar&#91;'hugo_deployment_data']&#91;'home_dir'] }}\n    - runas: {{ pillar&#91;'hugo_deployment_data']&#91;'user'] }}\n    - creates: {{ pillar&#91;'hugo_deployment_data']&#91;'nginx_document_root'] }}\/{{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}\/index.html\n    - require:\n      - file: build_script\n      - cmd: hugo_site_repo\n      - file: nginx_document_root<\/code><\/pre>\n<p>Tr\u1ea1ng th\u00e1i n\u00e0y s\u1eed d\u1ee5ng nhi\u1ec1u h\u01a1n m\u1ed9t m\u00f4-\u0111un. M\u00f4-\u0111un \u0111\u1ea7u ti\u00ean s\u1ebd t\u1ea3i xu\u1ed1ng t\u1ec7p&nbsp;<code>deploy.sh<\/code>t\u1eeb salt master v\u00e0 \u0111\u1eb7t t\u1ec7p \u0111\u00f3 v\u00e0o minion. T\u1eadp l\u1ec7nh n\u00e0y s\u1ebd ch\u1ecbu tr\u00e1ch nhi\u1ec7m bi\u00ean d\u1ecbch c\u00e1c t\u1ec7p trang web Hugo c\u1ee7a b\u1ea1n. Sau \u0111\u00f3, m\u00f4-\u0111un th\u1ee9 hai g\u1ecdi t\u1eadp l\u1ec7nh \u0111\u00f3. M\u00f4-\u0111un \u0111\u1ea7u ti\u00ean \u0111\u01b0\u1ee3c li\u1ec7t k\u00ea l\u00e0 y\u00eau c\u1ea7u c\u1ee7a m\u00f4-\u0111un th\u1ee9 hai, c\u00f9ng v\u1edbi l\u1ec7nh Git clone v\u00e0 vi\u1ec7c t\u1ea1o th\u01b0 m\u1ee5c g\u1ed1c c\u1ee7a t\u00e0i li\u1ec7u<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: T\u00f9y&nbsp;<code>- creates<\/code>ch\u1ecdn trong m\u00f4-\u0111un th\u1ee9 hai \u0111\u1ea3m b\u1ea3o r\u1eb1ng Salt kh\u00f4ng x\u00e2y d\u1ef1ng l\u1ea1i Hugo n\u1ebfu tr\u1ea1ng th\u00e1i \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng l\u1ea1i cho minion.<\/p>\n<p>2.T\u1ea1o&nbsp;<code>deploy.sh<\/code>t\u1eadp l\u1ec7nh trong&nbsp;<code>files\/<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\ncd {{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}\nhugo --destination={{ pillar&#91;'hugo_deployment_data']&#91;'nginx_document_root'] }}\/{{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}<\/code><\/pre>\n<p>H\u00e0m x\u00e2y d\u1ef1ng c\u1ee7a Hugo \u0111\u01b0\u1ee3c g\u1ecdi v\u1edbi g\u1ed1c t\u00e0i li\u1ec7u NGINX l\u00e0 \u0111\u00edch \u0111\u1ebfn cho c\u00e1c t\u1ec7p \u0111\u01b0\u1ee3c x\u00e2y d\u1ef1ng.<\/p>\n<p>3.C\u1eadp nh\u1eadt&nbsp;<code>init.sls<\/code>\u0111\u1ec3 bao g\u1ed3m t\u1ec7p m\u1edbi&nbsp;<code>config.sls<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>include:\n  - hugo.install\n  - hugo.config\n  - hugo.service<\/code><\/pre>\n<h3 id=\"push-the-salt-formula-updates-to-github\">\u0110\u1ea9y c\u00e1c b\u1ea3n c\u1eadp nh\u1eadt c\u00f4ng th\u1ee9c Salt&nbsp;l\u00ean GitHub<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#push-the-salt-formula-updates-to-github\"><\/a><\/h3>\n<p>T\u1ec7p tr\u1ea1ng th\u00e1i c\u1ee7a b\u1ea1n b\u00e2y gi\u1edd s\u1ebd c\u00f3 nh\u1eefng n\u1ed9i dung sau:&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/init-full.sls\">init.sls<\/a>&nbsp;,&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/install-partial.sls\">install.sls<\/a>&nbsp;,&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/config-partial.sls\">config.sls<\/a>&nbsp;,&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/service-partial.sls\">service.sls<\/a>&nbsp;.<\/p>\n<p>C\u00e1c t\u1eadp tin c\u00f3 trong kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c Salt c\u1ee7a b\u1ea1n ph\u1ea3i l\u00e0:<\/p>\n<pre class=\"wp-block-code\"><code>hugo\n\u251c\u2500\u2500 config.sls\n\u251c\u2500\u2500 files\n\u2502&nbsp;&nbsp; \u251c\u2500\u2500 deploy.sh\n\u2502&nbsp;&nbsp; \u2514\u2500\u2500 hugo_site\n\u251c\u2500\u2500 init.sls\n\u251c\u2500\u2500 install.sls\n\u2514\u2500\u2500 service.sls<\/code><\/pre>\n<p>1.S\u1eafp x\u1ebfp t\u1ea5t c\u1ea3 c\u00e1c thay \u0111\u1ed5i b\u1ea1n \u0111\u00e3 th\u1ef1c hi\u1ec7n \u0111\u1ed1i v\u1edbi t\u1ec7p c\u00f4ng th\u1ee9c Salt c\u1ee5c b\u1ed9 c\u1ee7a m\u00ecnh theo c\u00e1c b\u01b0\u1edbc tr\u01b0\u1edbc \u0111\u00f3, sau \u0111\u00f3 x\u00e1c nh\u1eadn c\u00e1c thay \u0111\u1ed5i:<\/p>\n<pre class=\"wp-block-code\"><code>cd ~\/hugo-webserver-salt-formula\ngit add .\ngit commit -m \"Deploy the Hugo site\"<\/code><\/pre>\n<p>2.\u0110\u1ea9y cam k\u1ebft v\u00e0o kho l\u01b0u tr\u1eef GitHub c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>git push origin master<\/code><\/pre>\n<h3 id=\"create-the-salt-pillar-file\">T\u1ea1o Salt Pillar File<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#create-the-salt-pillar-file\"><\/a><\/h3>\n<p>1.M\u1edf&nbsp;<code>\/etc\/salt\/master<\/code>tr\u00ean Salt master trong tr\u00ecnh so\u1ea1n th\u1ea3o v\u0103n b\u1ea3n. B\u1ecf ch\u00fa th\u00edch&nbsp;<code>pillar_roots<\/code>ph\u1ea7n:<\/p>\n<pre class=\"wp-block-code\"><code>pillar_roots:\n  base:\n    - \/srv\/pillar<\/code><\/pre>\n<p><code>pillar_roots<\/code>th\u1ef1c hi\u1ec7n ch\u1ee9c n\u0103ng t\u01b0\u01a1ng t\u1ef1 nh\u01b0&nbsp;<code>file_roots<\/code>: n\u00f3 ch\u1ec9 \u0111\u1ecbnh n\u01a1i d\u1eef li\u1ec7u Pillar \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef tr\u00ean h\u1ec7 th\u1ed1ng t\u1eadp tin c\u1ee7a m\u00e1y ch\u1ee7.<\/p>\n<p>2.Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Salt tr\u00ean m\u00e1y ch\u1ee7 ch\u00ednh \u0111\u1ec3 k\u00edch ho\u1ea1t c\u00e1c thay \u0111\u1ed5i trong&nbsp;<code>\/etc\/salt\/master<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>sudo systemctl restart salt-master\n<\/code><\/pre>\n<p>3.T\u1ea1o&nbsp;<code>\/srv\/pillar<\/code>th\u01b0 m\u1ee5c tr\u00ean m\u00e1y ch\u1ee7 Salt:<\/p>\n<pre class=\"wp-block-code\"><code>sudo mkdir \/srv\/pillar\n<\/code><\/pre>\n<p>4.T\u1ea1o m\u1ed9t&nbsp;<code>example-hugo-site.sls<\/code>t\u1ec7p&nbsp;<code>\/srv\/pillar<\/code>\u0111\u1ec3 ch\u1ee9a d\u1eef li\u1ec7u Pillar cho minion. T\u1ec7p n\u00e0y s\u1eed d\u1ee5ng c\u00fa ph\u00e1p YAML gi\u1ed1ng nh\u01b0 c\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i kh\u00e1c. Thay th\u1ebf c\u00e1c gi\u00e1 tr\u1ecb cho&nbsp;<code>github_account<\/code>v\u00e0&nbsp;<code>domain_name<\/code>b\u1eb1ng t\u00e0i kho\u1ea3n GitHub v\u00e0 t\u00ean mi\u1ec1n c\u1ee7a trang web c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>hugo_deployment_data:\n  hugo_version: 0.49\n  group: hugo\n  user: hugo\n  home_dir: \/home\/hugo\n  github_account: your_github_user\n  site_repo_name: example-hugo-site\n  nginx_document_root: \/var\/www\n  domain_name: yourdomain.com<\/code><\/pre>\n<p>5.T\u1ea1o m\u1ed9t&nbsp;<code>top.sls<\/code>t\u1ec7p trong&nbsp;<code>\/srv\/pillar<\/code>. T\u01b0\u01a1ng t\u1ef1 nh\u01b0 t\u1ec7p Top trong c\u00e2y tr\u1ea1ng th\u00e1i c\u1ee7a b\u1ea1n, t\u1ec7p Top c\u1ee7a Pillar \u00e1nh x\u1ea1 d\u1eef li\u1ec7u Pillar th\u00e0nh c\u00e1c minion:<\/p>\n<pre class=\"wp-block-code\"><code>base:\n  'hugo-webserver':\n    - example-hugo-site<\/code><\/pre>\n<h3 id=\"apply-state-updates-to-the-minion\">\u00c1p d\u1ee5ng C\u1eadp nh\u1eadt tr\u1ea1ng th\u00e1i cho Minion<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#apply-state-updates-to-the-minion\"><\/a><\/h3>\n<p>Tr\u00ean Salt master, \u00e1p d\u1ee5ng tr\u1ea1ng th\u00e1i m\u1edbi cho t\u1ea5t c\u1ea3 minion:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt '*' state.apply\n<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: Trong h\u01b0\u1edbng d\u1eabn n\u00e0y ch\u1ec9 c\u00f3 m\u1ed9t minion, nh\u01b0ng Salt c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng globbing theo ki\u1ec3u shell v\u00e0 bi\u1ec3u th\u1ee9c ch\u00ednh quy \u0111\u1ec3&nbsp;<a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/targeting\/globbing.html\" target=\"_blank\" rel=\"noreferrer noopener\">kh\u1edbp v\u1edbi ID minion<\/a>&nbsp;khi b\u1ea1n c\u00f3 nhi\u1ec1u h\u01a1n m\u1ed9t. V\u00ed d\u1ee5, l\u1ec7nh n\u00e0y s\u1ebd ch\u1ea1y highstate tr\u00ean t\u1ea5t c\u1ea3 c\u00e1c minion c\u00f3 ID b\u1eaft \u0111\u1ea7u b\u1eb1ng&nbsp;<code>hugo<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt 'hugo*' state.apply<\/code><\/pre>\n<p>N\u1ebfu kh\u00f4ng c\u00f3 thay \u0111\u1ed5i n\u00e0o \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n, h\u00e3y th\u1eed t\u1ea3i th\u1ee7 c\u00f4ng c\u00e1c b\u1ea3n c\u1eadp nh\u1eadt c\u00f4ng th\u1ee9c Salt t\u1eeb GitHub r\u1ed3i ch\u1ea1y&nbsp;<code>state.apply<\/code>l\u1ea1i l\u1ec7nh:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt-run fileserver.update\n<\/code><\/pre>\n<p>Khi qu\u00e1 tr\u00ecnh ho\u00e0n t\u1ea5t, trang Hugo c\u1ee7a b\u1ea1n s\u1ebd hi\u1ec3n th\u1ecb tr\u00ean t\u00ean mi\u1ec1n c\u1ee7a b\u1ea1n.<\/p>\n<h2 id=\"deploy-site-updates-with-webhooks\">Tri\u1ec3n khai C\u1eadp nh\u1eadt Trang web b\u1eb1ng Webhooks<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#deploy-site-updates-with-webhooks\"><\/a><\/h2>\n<p>Trang web c\u1ee7a b\u1ea1n hi\u1ec7n \u0111\u00e3 \u0111\u01b0\u1ee3c tri\u1ec3n khai \u0111\u1ec3 s\u1ea3n xu\u1ea5t, nh\u01b0ng v\u1eabn ch\u01b0a c\u00f3 c\u01a1 ch\u1ebf t\u1ef1 \u0111\u1ed9ng n\u00e0o \u0111\u1ec3 c\u1eadp nh\u1eadt m\u00e1y ch\u1ee7 s\u1ea3n xu\u1ea5t khi b\u1ea1n c\u1eadp nh\u1eadt n\u1ed9i dung trang web Hugo c\u1ee7a m\u00ecnh. \u0110\u1ec3 c\u1eadp nh\u1eadt m\u00e1y ch\u1ee7 s\u1ea3n xu\u1ea5t, minion c\u1ee7a b\u1ea1n s\u1ebd c\u1ea7n:<\/p>\n<ol>\n<li>K\u00e9o nh\u1eefng thay \u0111\u1ed5i m\u1edbi nh\u1ea5t \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean&nbsp;<code>master<\/code>nh\u00e1nh kho l\u01b0u tr\u1eef trang Hugo c\u1ee7a b\u1ea1n tr\u00ean GitHub.<\/li>\n<li>Ch\u1ea1y quy tr\u00ecnh x\u00e2y d\u1ef1ng Hugo v\u1edbi n\u1ed9i dung m\u1edbi.<\/li>\n<\/ol>\n<p>C\u00f3 th\u1ec3 thay \u0111\u1ed5i t\u1eadp&nbsp;<code>deploy.sh<\/code>l\u1ec7nh \u0111\u1ec3 k\u00e9o c\u00e1c thay \u0111\u1ed5i t\u1eeb GitHub. Nh\u1eefng thay \u0111\u1ed5i t\u1eadp l\u1ec7nh n\u00e0y s\u1ebd \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n trong kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c Salt. Sau \u0111\u00f3, ch\u00fang t\u00f4i s\u1ebd thi\u1ebft l\u1eadp&nbsp;<em>webhooks<\/em>&nbsp;\u0111\u1ec3 th\u00f4ng b\u00e1o cho minion Salt r\u1eb1ng c\u00e1c b\u1ea3n c\u1eadp nh\u1eadt \u0111\u00e3 \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n cho trang web Hugo.<\/p>\n<p>Webhooks l\u00e0 c\u00e1c y\u00eau c\u1ea7u HTTP POST \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf v\u00e0 g\u1eedi b\u1edfi c\u00e1c h\u1ec7 th\u1ed1ng \u0111\u1ec3 truy\u1ec1n \u0111\u1ea1t m\u1ed9t s\u1ed1 lo\u1ea1i s\u1ef1 ki\u1ec7n quan tr\u1ecdng. M\u00e1y ch\u1ee7 webhook l\u1eafng nghe c\u00e1c y\u00eau c\u1ea7u n\u00e0y v\u00e0 sau \u0111\u00f3 th\u1ef1c hi\u1ec7n m\u1ed9t s\u1ed1 h\u00e0nh \u0111\u1ed9ng khi nh\u1eadn \u0111\u01b0\u1ee3c y\u00eau c\u1ea7u. V\u00ed d\u1ee5: kho l\u01b0u tr\u1eef GitHub c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh \u0111\u1ec3 g\u1eedi th\u00f4ng b\u00e1o webhook b\u1ea5t c\u1ee9 khi n\u00e0o c\u00f3 l\u1ec7nh \u0111\u1ea9y \u0111\u1ebfn kho l\u01b0u tr\u1eef. \u0110\u00e2y l\u00e0 lo\u1ea1i th\u00f4ng b\u00e1o m\u00e0 ch\u00fang ta s\u1ebd c\u1ea5u h\u00ecnh v\u00e0 minion Salt s\u1ebd ch\u1ea1y m\u00e1y ch\u1ee7 webhook \u0111\u1ec3 nh\u1eadn ch\u00fang.&nbsp;<a href=\"https:\/\/developer.github.com\/webhooks\/\" target=\"_blank\" rel=\"noreferrer noopener\">C\u00e1c th\u00f4ng b\u00e1o s\u1ef1 ki\u1ec7n kh\u00e1c<\/a>&nbsp;c\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp tr\u00ean GitHub.<\/p>\n<h3 id=\"set-up-a-webhook-server-on-the-salt-minion\">Thi\u1ebft l\u1eadp m\u00e1y ch\u1ee7 Webhook tr\u00ean Salt Minion<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#set-up-a-webhook-server-on-the-salt-minion\"><\/a><\/h3>\n<p>1.Trong kho l\u01b0u tr\u1eef c\u00f4ng th\u1ee9c Salt c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n, h\u00e3y th\u00eam&nbsp;<code>webhook_pkg<\/code>tr\u1ea1ng th\u00e1i m\u1edbi v\u00e0o&nbsp;<code>install.sls<\/code>\u0111\u1ec3 c\u00e0i \u0111\u1eb7t&nbsp;<a href=\"https:\/\/github.com\/adnanh\/webhook\/\" target=\"_blank\" rel=\"noreferrer noopener\">g\u00f3i m\u00e1y ch\u1ee7 webhook theo adnanh<\/a>&nbsp;:<\/p>\n<pre class=\"wp-block-code\"><code>webhook_pkg:\n  pkg.installed:\n    - name: webhook<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: M\u00e1y ch\u1ee7 webhook \u0111\u01b0\u1ee3c adnanh vi\u1ebft b\u1eb1ng Go l\u00e0 m\u1ed9t tri\u1ec3n khai ph\u1ed5 bi\u1ebfn c\u1ee7a kh\u00e1i ni\u1ec7m n\u00e0y, nh\u01b0ng v\u1eabn c\u00f3 th\u1ec3 vi\u1ebft c\u00e1c m\u00e1y ch\u1ee7 HTTP kh\u00e1c \u0111\u1ec3 ph\u00e2n t\u00edch c\u00fa ph\u00e1p t\u1ea3i tr\u1ecdng webhook.<\/p>\n<p>2.Th\u00eam hai th\u00e0nh ph\u1ea7n m\u1edbi v\u00e0o&nbsp;<code>config.sls<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>webhook_systemd_unit:\n  file.managed:\n    - name: '\/etc\/systemd\/system\/webhook.service'\n    - source: salt:\/\/hugo\/files\/webhook.service\n    - user: root\n    - group: root\n    - mode: 0644\n    - template: jinja\n    - require:\n      - pkg: webhook_pkg\n  module.run:\n    - name: service.systemctl_reload\n    - onchanges:\n      - file: webhook_systemd_unit\n\nwebhook_config:\n  file.managed:\n    - name: '\/etc\/webhook.conf'\n    - source: salt:\/\/hugo\/files\/webhook.conf\n    - user: root\n    - group: {{ pillar&#91;'hugo_deployment_data']&#91;'group'] }}\n    - mode: 0640\n    - template: jinja\n    - require:\n      - pkg: webhook_pkg\n      - group: hugo_group<\/code><\/pre>\n<p>Tr\u1ea1ng th\u00e1i \u0111\u1ea7u ti\u00ean t\u1ea1o&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/introduction-to-systemctl\/\">t\u1ec7p \u0111\u01a1n v\u1ecb systemd<\/a>&nbsp;cho d\u1ecbch v\u1ee5 webhook. Tr\u1ea1ng th\u00e1i th\u1ee9 hai t\u1ea1o c\u1ea5u h\u00ecnh webhook. M\u00e1y ch\u1ee7 webhook \u0111\u1ecdc c\u1ea5u h\u00ecnh v\u00e0 t\u1ea1o URL webhook t\u1eeb \u0111\u00f3.<\/p>\n<p>3.T\u1ea1o m\u1ed9t&nbsp;<code>webhook.service<\/code>t\u1ec7p trong th\u01b0 m\u1ee5c kho l\u01b0u tr\u1eef c\u1ee7a b\u1ea1n&nbsp;<code>files\/<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=Small server for creating HTTP endpoints (hooks)\nDocumentation=https:\/\/github.com\/adnanh\/webhook\/\n\n&#91;Service]\nUser={{ pillar&#91;'hugo_deployment_data']&#91;'user'] }}\nExecStart=\/usr\/bin\/webhook -nopanic -hooks \/etc\/webhook.conf\n\n&#91;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p>4.T\u1ea1o m\u1ed9t&nbsp;<code>webhook.conf<\/code>t\u1ec7p trong th\u01b0 m\u1ee5c kho l\u01b0u tr\u1eef c\u1ee7a b\u1ea1n&nbsp;<code>files\/<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>&#91;\n  {\n    \"id\": \"github_push\",\n    \"execute-command\": \"{{ pillar&#91;'hugo_deployment_data']&#91;'home_dir'] }}\/deploy.sh\",\n    \"command-working-directory\": \"{{ pillar&#91;'hugo_deployment_data']&#91;'home_dir'] }}\",\n    \"trigger-rule\":\n    {\n      \"and\":\n      &#91;\n        {\n          \"match\":\n          {\n            \"type\": \"payload-hash-sha1\",\n            \"secret\": \"{{ pillar&#91;'hugo_deployment_data']&#91;'webhook_secret'] }}\",\n            \"parameter\":\n            {\n              \"source\": \"header\",\n              \"name\": \"X-Hub-Signature\"\n            }\n          }\n        },\n        {\n          \"match\":\n          {\n            \"type\": \"value\",\n            \"value\": \"refs\/heads\/master\",\n            \"parameter\":\n            {\n              \"source\": \"payload\",\n              \"name\": \"ref\"\n            }\n          }\n        }\n      ]\n    }\n  }\n]<\/code><\/pre>\n<p>C\u1ea5u h\u00ecnh n\u00e0y thi\u1ebft l\u1eadp m\u1ed9t URL c\u00f3 t\u00ean l\u00e0&nbsp;<code>http:\/\/example.com:9000\/hooks\/github_push<\/code>, trong \u0111\u00f3 th\u00e0nh ph\u1ea7n cu\u1ed1i c\u00f9ng c\u1ee7a URL \u0111\u01b0\u1ee3c l\u1ea5y t\u1eeb gi\u00e1 tr\u1ecb c\u1ee7a c\u1ea5u h\u00ecnh&nbsp;<code>id<\/code>.<\/p>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: M\u00e1y ch\u1ee7 webhook ch\u1ea1y tr\u00ean c\u1ed5ng 9000 v\u00e0 \u0111\u1eb7t webhook c\u1ee7a b\u1ea1n b\u00ean trong m\u1ed9t&nbsp;<code>hooks\/<\/code>th\u01b0 m\u1ee5c theo m\u1eb7c \u0111\u1ecbnh.<\/p>\n<p>Khi y\u00eau c\u1ea7u POST \u0111\u01b0\u1ee3c g\u1eedi \u0111\u1ebfn URL:<\/p>\n<ul>\n<li>M\u00e1y ch\u1ee7 webhook ki\u1ec3m tra xem d\u1eef li\u1ec7u ti\u00eau \u0111\u1ec1 v\u00e0 d\u1eef li\u1ec7u t\u1ea3i tr\u1ecdng t\u1eeb y\u00eau c\u1ea7u c\u00f3 \u0111\u00e1p \u1ee9ng c\u00e1c quy t\u1eafc trong&nbsp;<code>trigger-rule<\/code>t\u1eeb \u0111i\u1ec3n hay kh\u00f4ng, \u0111\u00f3 l\u00e0:\n<ul>\n<li>M\u00e3 b\u0103m SHA1 c\u1ee7a b\u00ed m\u1eadt webhook c\u1ee7a m\u00e1y ch\u1ee7 kh\u1edbp v\u1edbi b\u00ed m\u1eadt trong ti\u00eau \u0111\u1ec1 y\u00eau c\u1ea7u. \u0110i\u1ec1u n\u00e0y ng\u0103n nh\u1eefng ng\u01b0\u1eddi kh\u00f4ng bi\u1ebft b\u00ed m\u1eadt webhook c\u1ee7a b\u1ea1n k\u00edch ho\u1ea1t h\u00e0nh \u0111\u1ed9ng c\u1ee7a webhook.<\/li>\n<li>Tham&nbsp;<code>ref<\/code>s\u1ed1 trong payload kh\u1edbp v\u1edbi&nbsp;<code>refs\/heads\/master<\/code>. \u0110i\u1ec1u n\u00e0y \u0111\u1ea3m b\u1ea3o r\u1eb1ng ch\u1ec9 c\u00f3 c\u00e1c l\u1ec7nh \u0111\u1ea9y \u0111\u1ebfn&nbsp;<code>master<\/code>nh\u00e1nh m\u1edbi k\u00edch ho\u1ea1t h\u00e0nh \u0111\u1ed9ng.<\/li>\n<\/ul>\n<\/li>\n<li>N\u1ebfu c\u00e1c quy t\u1eafc \u0111\u01b0\u1ee3c \u0111\u00e1p \u1ee9ng, l\u1ec7nh \u0111\u01b0\u1ee3c li\u1ec7t k\u00ea trong \u0111\u00f3&nbsp;<code>execute-command<\/code>s\u1ebd \u0111\u01b0\u1ee3c ch\u1ea1y, \u0111\u00f3 ch\u00ednh l\u00e0&nbsp;<code>deploy.sh<\/code>t\u1eadp l\u1ec7nh.<\/li>\n<\/ul>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: B\u1ea1n c\u00f3 th\u1ec3 xem th\u00eam t\u00e0i li\u1ec7u v\u1ec1 c\u00e1c t\u00f9y ch\u1ecdn c\u1ea5u h\u00ecnh webhook tr\u00ean&nbsp;<a href=\"https:\/\/github.com\/adnanh\/webhook\/\" target=\"_blank\" rel=\"noreferrer noopener\">kho l\u01b0u tr\u1eef GitHub<\/a>&nbsp;c\u1ee7a d\u1ef1 \u00e1n .<\/p>\n<p>5.Th\u00eam tr\u1ea1ng th\u00e1i m\u1edbi&nbsp;<code>webhook_service<\/code>v\u00e0o tr\u1ea1ng&nbsp;<code>service.sls<\/code>th\u00e1i cho ph\u00e9p v\u00e0 kh\u1edfi \u0111\u1ed9ng m\u00e1y ch\u1ee7 webhook:<\/p>\n<pre class=\"wp-block-code\"><code>webhook_service:\n  service.running:\n    - name: webhook\n    - enable: True\n    - watch:\n      - file: webhook_config\n      - module: webhook_systemd_unit<\/code><\/pre>\n<p>6.C\u1eadp nh\u1eadt&nbsp;<code>deploy.sh<\/code>t\u1eadp l\u1ec7nh \u0111\u1ec3 n\u00f3 c\u00f3 th\u1ec3 l\u1ea5y nh\u1eefng thay \u0111\u1ed5i&nbsp;<code>master<\/code>tr\u01b0\u1edbc khi x\u00e2y d\u1ef1ng trang web:<\/p>\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\ncd {{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}\ngit pull origin master\nhugo --destination={{ pillar&#91;'hugo_deployment_data']&#91;'nginx_document_root'] }}\/\/{{ pillar&#91;'hugo_deployment_data']&#91;'site_repo_name'] }}<\/code><\/pre>\n<p>7.C\u00e1c t\u1ec7p tr\u1ea1ng th\u00e1i c\u1ee7a b\u1ea1n b\u00e2y gi\u1edd s\u1ebd c\u00f3 c\u00e1c n\u1ed9i dung sau:&nbsp; <a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/init-full.sls\">init.sls&nbsp;<\/a><em>(unchanged)<\/em>&nbsp;,&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/install-full.sls\">install.sls<\/a>&nbsp;,&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/config-full.sls\">config.sls<\/a>&nbsp;,&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/service-full.sls\">service.sls<\/a>&nbsp;. L\u01b0u c\u00e1c thay \u0111\u1ed5i \u0111\u00e3 th\u1ef1c hi\u1ec7n \u0111\u1ed1i v\u1edbi c\u00e1c t\u1ec7p Salt c\u1ee7a b\u1ea1n, sau \u0111\u00f3 cam k\u1ebft v\u00e0 \u0111\u1ea9y ch\u00fang l\u00ean GitHub:<\/p>\n<pre class=\"wp-block-code\"><code>cd ~\/hugo-webserver-salt-formula\ngit add .\ngit commit -m \"Webhook server states\"\ngit push origin master<\/code><\/pre>\n<p>8.Tr\u00ean Salt master, th\u00eam a&nbsp;<code>webhook_secret<\/code>v\u00e0o&nbsp;<code>example-hugo-site.sls<\/code>Pillar. B\u00ed m\u1eadt c\u1ee7a b\u1ea1n ph\u1ea3i l\u00e0 m\u1ed9t chu\u1ed7i ch\u1eef s\u1ed1 ph\u1ee9c t\u1ea1p, ng\u1eabu nhi\u00ean.<\/p>\n<pre class=\"wp-block-code\"><code>hugo_deployment_data:\n  # &#91;...]\n  webhook_secret: your_webhook_secret<\/code><\/pre>\n<p>9.T\u1eeb Salt master, \u00e1p d\u1ee5ng c\u00f4ng th\u1ee9c c\u1eadp nh\u1eadt cho minion:<\/p>\n<pre class=\"wp-block-code\"><code>sudo salt-run fileserver.update\nsudo salt 'hugo-webserver' state.apply<\/code><\/pre>\n<p>10.M\u00e1y ch\u1ee7 webhook c\u1ee7a b\u1ea1n b\u00e2y gi\u1edd s\u1ebd ch\u1ea1y tr\u00ean minion. N\u1ebfu b\u1ea1n ch\u1ea1y&nbsp;<code>curl<\/code>tr\u00ean n\u00f3, b\u1ea1n s\u1ebd th\u1ea5y:<\/p>\n<pre class=\"wp-block-code\"><code>curl http:\/\/example.com:9000\/hooks\/github_push\n<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>Hook rules were not satisfied.\u23ce\n<\/code><\/pre>\n<h3 id=\"configure-a-webhook-on-github\">C\u1ea5u h\u00ecnh Webhook tr\u00ean GitHub<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#configure-a-webhook-on-github\"><\/a><\/h3>\n<ol>\n<li>Truy c\u1eadp kho l\u01b0u tr\u1eef trang Hugo m\u1eabu c\u1ee7a b\u1ea1n tr\u00ean GitHub v\u00e0 \u0111i\u1ec1u h\u01b0\u1edbng \u0111\u1ebfn ph\u1ea7n&nbsp;<strong>Webhooks<\/strong>&nbsp;c\u1ee7a tab&nbsp;<strong>C\u00e0i \u0111\u1eb7t<\/strong>&nbsp;. Nh\u1ea5p v\u00e0o n\u00fat&nbsp;<strong>Th\u00eam webhook<\/strong>&nbsp;:<img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/github-add-webhook-button_hub1ca24311bcea8fac4966a91d0c3f034_104138_2132x0_resize_q71_bgfafafc_catmullrom_3.jpg\" alt=\"GitHub - Add Webhook Button\"><\/li>\n<li>\u0110i\u1ec1n v\u00e0o m\u1eabu:\n<ul>\n<li>Nh\u1eadp&nbsp;<code>http:\/\/example.com:9000\/hooks\/github_push<\/code>URL t\u1ea3i tr\u1ecdng (thay th\u1ebf&nbsp;<code>example.com<\/code>b\u1eb1ng t\u00ean mi\u1ec1n c\u1ee7a b\u1ea1n).<\/li>\n<li>Ch\u1ecdn&nbsp;<code>application\/json<\/code>lo\u1ea1i n\u1ed9i dung.<\/li>\n<li>D\u00e1n b\u00ed m\u1eadt webhook m\u00e0 b\u1ea1n \u0111\u00e3 th\u00eam tr\u01b0\u1edbc \u0111\u00f3 v\u00e0o Salt Pillar.<\/li>\n<\/ul>\n<p>Theo m\u1eb7c \u0111\u1ecbnh, webhook \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh \u0111\u1ec3 th\u00f4ng b\u00e1o v\u1ec1 c\u00e1c s\u1ef1 ki\u1ec7n \u0111\u1ea9y. Gi\u1eef nguy\u00ean t\u00f9y ch\u1ecdn n\u00e0y.<img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/github-new-webhook-config_hucefec64de087177818b475f8b0ec0839_165602_2160x0_resize_q71_bgfafafc_catmullrom_3.jpg\" alt=\"GitHub - New Webhook Configuration\"><\/li>\n<li>Nh\u1ea5p v\u00e0o n\u00fat&nbsp;<strong>Th\u00eam webhook<\/strong>&nbsp;m\u00e0u xanh l\u00e1 c\u00e2y \u0111\u1ec3 ho\u00e0n t\u1ea5t thi\u1ebft l\u1eadp.<\/li>\n<\/ol>\n<h3 id=\"update-the-hugo-site\">C\u1eadp nh\u1eadt trang web Hugo<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#update-the-hugo-site\"><\/a><\/h3>\n<p>1.Trong kho l\u01b0u tr\u1eef trang Hugo c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n, h\u00e3y t\u1ea1o b\u00e0i \u0111\u0103ng m\u1edbi b\u1eb1ng t\u00ednh n\u0103ng&nbsp;<a href=\"https:\/\/gohugo.io\/content-management\/archetypes\/\" target=\"_blank\" rel=\"noreferrer noopener\"><em>nguy\u00ean m\u1eabu<\/em><\/a>&nbsp;c\u1ee7a Hugo :<\/p>\n<pre class=\"wp-block-code\"><code>hugo new post\/test-post.md\n<\/code><\/pre>\n<p>2.L\u1ec7nh n\u00e0y t\u1ea1o m\u1ed9t t\u00e0i li\u1ec7u Markdown m\u1edbi \u0111\u01b0\u1ee3c \u0111i\u1ec1n m\u1ed9t ph\u1ea7n trong&nbsp;<code>content\/post\/<\/code>. M\u1edf t\u1ec7p n\u00e0y trong tr\u00ecnh so\u1ea1n th\u1ea3o c\u1ee7a b\u1ea1n, x\u00f3a&nbsp;<code>draft: true<\/code>d\u00f2ng kh\u1ecfi&nbsp;<a href=\"https:\/\/gohugo.io\/content-management\/front-matter\/\" target=\"_blank\" rel=\"noreferrer noopener\"><em>frontmatter<\/em><\/a>&nbsp;v\u00e0 th\u00eam m\u1ed9t s\u1ed1 v\u0103n b\u1ea3n th\u00e2n b\u00e0i:<\/p>\n<pre class=\"wp-block-code\"><code>---\ntitle: \"Test Post\"\ndate: 2018-10-19T11:39:15-04:00\n---\n\nTest post body text<\/code><\/pre>\n<p>3.N\u1ebfu b\u1ea1n ch\u1ea1y&nbsp;<code>hugo server<\/code>trong th\u01b0 m\u1ee5c kho l\u01b0u tr\u1eef, b\u1ea1n c\u00f3 th\u1ec3 th\u1ea5y b\u00e0i \u0111\u0103ng m\u1edbi:<img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/hugo-test-post_huac89b5a4754a6a9b21ceda269ca6a918_32629_1388x0_resize_q71_bgfafafc_catmullrom_3.jpg\" alt=\"Hugo Home Page - Test Post\"><\/p>\n<p>4.Cam k\u1ebft v\u00e0 \u0111\u1ea9y b\u00e0i \u0111\u0103ng m\u1edbi l\u00ean GitHub:<\/p>\n<pre class=\"wp-block-code\"><code>cd ~\/example-hugo-site\ngit add .\ngit commit -m \"Test post\"\ngit push origin master<\/code><\/pre>\n<p>5.Truy c\u1eadp t\u00ean mi\u1ec1n c\u1ee7a b\u1ea1n tr\u00ean tr\u00ecnh duy\u1ec7t; b\u00e0i \u0111\u0103ng th\u1eed nghi\u1ec7m c\u1ee7a b\u1ea1n s\u1ebd t\u1ef1 \u0111\u1ed9ng xu\u1ea5t hi\u1ec7n.<\/p>\n<p>Ghi ch\u00fa<\/p>\n<p>N\u1ebfu b\u00e0i \u0111\u0103ng c\u1ee7a b\u1ea1n kh\u00f4ng xu\u1ea5t hi\u1ec7n, h\u00e3y xem l\u1ea1i ph\u1ea7n&nbsp;<strong>Giao h\u00e0ng g\u1ea7n \u0111\u00e2y<\/strong>&nbsp;\u1edf cu\u1ed1i trang c\u1ea5u h\u00ecnh webhook c\u1ee7a b\u1ea1n tr\u00ean GitHub:<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/github-webhook-recent-deliveries_hu75ba7c6ca1bd2e4dc4cb62d5b2888cfb_28788_1582x0_resize_q71_bgfafafc_catmullrom_3.jpg\" alt=\"GitHub Webhook - Recent Deliveries\" title=\"GitHub Webhook - Recent Deliveries\"\/><\/figure>\n<p>N\u1ebfu b\u1ea1n nh\u1ea5p v\u00e0o m\u1ed9t l\u1ea7n giao h\u00e0ng, th\u00f4ng tin \u0111\u1ea7y \u0111\u1ee7 v\u1ec1 ti\u00eau \u0111\u1ec1 y\u00eau c\u1ea7u v\u00e0 t\u1ea3i tr\u1ecdng c\u0169ng nh\u01b0 ph\u1ea3n h\u1ed3i c\u1ee7a m\u00e1y ch\u1ee7 s\u1ebd \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb v\u00e0 nh\u1eefng th\u00f4ng tin n\u00e0y c\u00f3 th\u1ec3 cung c\u1ea5p m\u1ed9t s\u1ed1 th\u00f4ng tin kh\u1eafc ph\u1ee5c s\u1ef1 c\u1ed1. Ch\u1ec9nh s\u1eeda t\u1ec7p&nbsp;<code>webhook.service<\/code>\u0111\u1ec3 kh\u1edfi \u0111\u1ed9ng d\u1ecbch v\u1ee5 \u1edf&nbsp;<a href=\"https:\/\/github.com\/adnanh\/webhook\/blob\/master\/docs\/Webhook-Parameters.md\" target=\"_blank\" rel=\"noreferrer noopener\">ch\u1ebf \u0111\u1ed9 chi ti\u1ebft<\/a>&nbsp;c\u00f3 th\u1ec3 h\u1eefu \u00edch.<\/p>\n<h2 id=\"next-steps\">C\u00e1c b\u01b0\u1edbc ti\u1ebfp theo<a href=\"https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/#next-steps\"><\/a><\/h2>\n<p>C\u1ea5u h\u00ecnh Salt hi\u1ec7n t\u1ea1i c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng l\u00e0m n\u1ec1n t\u1ea3ng cho c\u00e1c tri\u1ec3n khai ph\u1ee9c t\u1ea1p h\u01a1n:<\/p>\n<ul>\n<li>L\u01b0u tr\u1eef nhi\u1ec1u trang web Hugo b\u1eb1ng c\u00e1ch c\u1eadp nh\u1eadt Pillar v\u1edbi nhi\u1ec1u kho l\u01b0u tr\u1eef GitHub kh\u00e1c.<\/li>\n<li>L\u01b0u tr\u1eef nhi\u1ec1u lo\u1ea1i trang web t\u0129nh kh\u00e1c nhau b\u1eb1ng c\u00e1ch thay \u0111\u1ed5i c\u00f4ng th\u1ee9c Salt \u0111\u1ec3 h\u1ed7 tr\u1ee3 ch\u00fang.<\/li>\n<li>C\u00e2n b\u1eb1ng t\u1ea3i trang web c\u1ee7a b\u1ea1n b\u1eb1ng c\u00e1ch t\u1ea1o th\u00eam minion v\u00e0 \u00e1p d\u1ee5ng c\u00f9ng d\u1eef li\u1ec7u Pillar v\u00e0 tr\u1ea1ng th\u00e1i Salt cho ch\u00fang. Sau \u0111\u00f3, thi\u1ebft l\u1eadp NodeBalancer&nbsp;<a href=\"https:\/\/www.linode.com\/nodebalancers\" target=\"_blank\" rel=\"noreferrer noopener\">\u0111\u1ec3<\/a>&nbsp;h\u01b0\u1edbng l\u01b0u l\u01b0\u1ee3ng truy c\u1eadp \u0111\u1ebfn c\u00e1c minion.<\/li>\n<li>Thi\u1ebft l\u1eadp nh\u00e1nh ph\u00e1t tri\u1ec3n v\u00e0 m\u00e1y ch\u1ee7 ph\u00e1t tri\u1ec3n ri\u00eang bi\u1ec7t v\u1edbi t\u00ednh n\u0103ng m\u00f4i tr\u01b0\u1eddng c\u1ee7a Salt.<\/li>\n<\/ul>\n<h2 id=\"more-information\">Th\u00f4ng tin th\u00eam<\/h2>\n<p>B\u1ea1n c\u00f3 th\u1ec3 mu\u1ed1n tham kh\u1ea3o c\u00e1c ngu\u1ed3n sau \u0111\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin v\u1ec1 ch\u1ee7 \u0111\u1ec1 n\u00e0y. M\u1eb7c d\u00f9 ch\u00fang t\u00f4i cung c\u1ea5p v\u1edbi hy v\u1ecdng r\u1eb1ng ch\u00fang s\u1ebd h\u1eefu \u00edch, nh\u01b0ng xin l\u01b0u \u00fd r\u1eb1ng ch\u00fang t\u00f4i kh\u00f4ng th\u1ec3 \u0111\u1ea3m b\u1ea3o t\u00ednh ch\u00ednh x\u00e1c ho\u1eb7c t\u00ednh k\u1ecbp th\u1eddi c\u1ee7a c\u00e1c t\u00e0i li\u1ec7u \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef b\u00ean ngo\u00e0i.<\/p>\n<ul>\n<li><a href=\"https:\/\/gohugo.io\/documentation\/\" target=\"_blank\" rel=\"noreferrer noopener\">T\u00e0i li\u1ec7u Hugo<\/a><\/li>\n<li><a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/tutorials\/gitfs.html#tutorial-gitfs\" target=\"_blank\" rel=\"noreferrer noopener\">T\u00e0i li\u1ec7u v\u1ec1 m\u00e1y ch\u1ee7 t\u1ec7p SaltStack Git<\/a><\/li>\n<li><a href=\"https:\/\/docs.saltproject.io\/en\/latest\/topics\/development\/conventions\/formulas.html\" target=\"_blank\" rel=\"noreferrer noopener\">T\u00e0i li\u1ec7u c\u00f4ng th\u1ee9c mu\u1ed1i SaltStack<\/a><\/li>\n<li><a href=\"https:\/\/developer.github.com\/webhooks\/\" target=\"_blank\" rel=\"noreferrer noopener\">Nh\u00e0 ph\u00e1t tri\u1ec3n GitHub &#8211; Webhooks<\/a><\/li>\n<\/ul>\n<p>Ngu\u1ed3n: https:\/\/www.linode.com\/docs\/guides\/automate-a-static-site-deployment-with-salt\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1ebd h\u01b0\u1edbng d\u1eabn tri\u1ec3n khai site t\u0129nh b\u1eb1ng&nbsp;SaltStack&nbsp;, \u0111\u00e2y l\u00e0 h\u1ec7 th\u1ed1ng qu\u1ea3n l\u00fd c\u1ea5u h\u00ecnh linh ho\u1ea1t. C\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh \u0111\u01b0\u1ee3c t\u1ea1o cho Salt s\u1ebd \u0111\u01b0\u1ee3c ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n b\u1eb1ng Git. C\u00e1c b\u1ea3n c\u1eadp nh\u1eadt cho m\u00e3 site t\u0129nh c\u1ee7a b\u1ea1n s\u1ebd \u0111\u01b0\u1ee3c t\u1ef1 \u0111\u1ed9ng truy\u1ec1n \u0111\u1ebfn h\u1ec7 th\u1ed1ng<\/p>\n","protected":false},"author":1,"featured_media":35990,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[124],"tags":[],"class_list":["post-34969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salt"],"_links":{"self":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/34969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/comments?post=34969"}],"version-history":[{"count":0,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/34969\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media\/35990"}],"wp:attachment":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media?parent=34969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/categories?post=34969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/tags?post=34969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}