2017-10-28 266 views
0

當前我正在研究使用打包器和碼頭構建構建管道。 這是我packer.json:在Packer腳本中更改文件(使用sed)會使文件保持不變

{ 
    "builders": [{ 
    "type": "docker", 
    "image": "php:7.0-apache", 
    "commit": true 
    }], 
    "provisioners": [ 
    { 
     "type": "file", 
     "source": "./", 
     "destination": "/var/www/html/" 
    }, 
    { 
     "type": "shell", 
     "inline": [ 
     "chown -R www-data:www-data /var/www/html", 
     "sed '/<Directory \\/var\\/www\\/>/,/<\\/Directory>/ s/AllowOverride None/AllowOverride all/' /etc/apache2/apache2.conf", 
     "sed '/<VirtualHost/,/<\\/VirtualHost>/ s/DocumentRoot \\/var\\/www\\/html/DocumentRoot \\/var\\/www\\/html\\/web/' /etc/apache2/sites-enabled/000-default.conf" 
     ] 
    } 
    ] 
} 

Shell腳本里面provisioners部分包含更改Apache的配置裏面的AllowOverrideDocumentRoot變量的一些sed命令。

當打包器運行這個腳本它工作得很好,我得到一個積極的sed輸出,所以sed似乎工作正常。但是在碼頭圖像中文件沒有改變。 複製file預配置器中的文件工作正常。

我在做什麼錯?

+0

請問您能否發佈相同的預期輸出? – RavinderSingh13

回答

2

看來你在你的sed命令中缺少-i(或--in-place)標誌。試一下:

"sed -i <expression> <file>"