{"id":382,"date":"2017-07-07T14:38:04","date_gmt":"2017-07-07T05:38:04","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2017\/07\/07\/pass_parameter_from_jenkins_job_to_ansible"},"modified":"2017-07-07T14:38:04","modified_gmt":"2017-07-07T05:38:04","slug":"pass_parameter_from_jenkins_job_to_ansible","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2017\/07\/07\/pass_parameter_from_jenkins_job_to_ansible\/","title":{"rendered":"Jenkins\u304b\u3089Ansible\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u3066\u30b8\u30e7\u30d6\u3092\u5b9f\u884c\u3059\u308b"},"content":{"rendered":"

\u524d\u7530\u3067\u3059\u3002
\n\u6700\u8fd1\u306f\u7d99\u7d9a\u7684\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30c4\u30fc\u30eb\u306bJenkins\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002
\n\u4eca\u307e\u3067\u305a\u3063\u3068CircleCI\u3092\u4f7f\u3063\u3066\u304d\u305f\u306e\u3067\u3001UI\u306a\u3069\u306b\u307e\u3060\u5168\u7136\u6163\u308c\u3066\u3044\u306a\u3044\u3067\u3059\u304c\u3001\u5c11\u3057\u305a\u3064\u899a\u3048\u3066\u3044\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u73fe\u5728\u6271\u3063\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3001Jenkins\u304b\u3089Ansible\u3092\u4f7f\u3063\u3066\u30b5\u30fc\u30d0\u306e\u74b0\u5883\u69cb\u7bc9\u3084\u30c7\u30d7\u30ed\u30a4\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\"\"<\/p>\n

\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3084Ansible\u306a\u3069\u306e\u69cb\u6210\u7ba1\u7406\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306fGitHub\u306a\u3069\u3067\u7ba1\u7406\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001DB\u306e\u63a5\u7d9a\u60c5\u5831\u306a\u3069\u306e\u74b0\u5883\u306b\u3088\u3063\u3066\u5024\u304c\u5909\u308f\u3063\u305f\u308a\u3001\u30bb\u30ad\u30e5\u30a2\u306b\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u30d1\u30e9\u30e1\u30fc\u30bf\u306a\u3069\u306f\u3001\u76f4\u63a5\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u8a18\u8f09\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001Jenkins\u3084CircleCI\u306a\u3069\u306e\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3057\u3001\u30c7\u30d7\u30ed\u30a4\u6642\u306b\u52d5\u7684\u306b\u30bb\u30c3\u30c8\u3057\u3066\u3042\u3052\u308b\u306e\u304c\u30bb\u30aa\u30ea\u30fc\u3060\u3068\u601d\u3044\u307e\u3059\u3002
\nJenkins\u304b\u3089Ansible(Jenkins Ansible plugin\u4f7f\u7528)\u3067\u30b5\u30fc\u30d0\u306e\u74b0\u5883\u69cb\u7bc9\u3092\u3059\u308b\u969b\u306b\u3001\u30b5\u30fc\u30d0\u3084\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u56fa\u6709\u306e\u60c5\u5831(DB\u306e\u63a5\u7d9a\u60c5\u5831\u306a\u3069)\u3092\u69cb\u7bc9\u5bfe\u8c61\u306e\u30b5\u30fc\u30d0\u306b\u6e21\u3057\u3066\u3042\u3052\u308b\u70ba\u3001\u3069\u3046\u3084\u3063\u3066\u6e21\u3059\u304b\u306e\u65b9\u6cd5\u3092\u8272\u3005\u8abf\u67fb\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u305d\u306e\u65b9\u6cd5\u3092\u66f8\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n\n\n\n
\u74b0\u5883<\/th>\n\u30d0\u30fc\u30b8\u30e7\u30f3<\/th>\n<\/tr>\n<\/thead>\n
Jenkins version<\/td>\n1.645<\/td>\n<\/tr>\n
Jenkins Ansible Plugin<\/a><\/td>\n0.6.2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Jenkins\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u8a2d\u5b9a<\/h2>\n

Jenkins\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u3001\u5168\u30b8\u30e7\u30d6\u5168\u4f53\u306e\u30b0\u30ed\u30fc\u30d0\u30eb\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3001\u30b8\u30e7\u30d6\u6bce\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u3042\u308a\u307e\u3059\u3002
\n\u305d\u308c\u305e\u308c\u3067\u540c\u3058\u540d\u524d\u3092\u8a2d\u5b9a\u3057\u305f\u5834\u5408\u306f\u3001\u30b8\u30e7\u30d6\u6bce\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u512a\u5148\u3055\u308c\u307e\u3059\u3002<\/strong>
\n\u30b1\u30fc\u30b9\u306b\u3088\u3063\u3066\u3001\u3069\u3061\u3089\u304b\u306b\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n

\u30b0\u30ed\u30fc\u30d0\u30eb\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8a2d\u5b9a\u65b9\u6cd5<\/h3>\n

Jenkins\u30c8\u30c3\u30d7 -> Jenkins\u306e\u7ba1\u7406 -> \u30b7\u30b9\u30c6\u30e0\u306e\u8a2d\u5b9a -> \u30b0\u30ed\u30fc\u30d0\u30eb\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u300c\u74b0\u5883\u5909\u6570\u300d\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9<\/code><\/p>\n

\u300c\u8ffd\u52a0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u8a2d\u5b9a\u3057\u305f\u3044\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

\"\"<\/p>\n

\u30b8\u30e7\u30d6\u6bce\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8a2d\u5b9a\u65b9\u6cd5<\/h3>\n

Jenkins\u30c8\u30c3\u30d7 -> \u8a2d\u5b9a\u3057\u305f\u3044\u30b8\u30e7\u30d6\u3092\u9078\u629e -> \u8a2d\u5b9a -> \u300c\u30d3\u30eb\u30c9\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u5316\u300d\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9<\/code><\/p>\n

\u300c\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8ffd\u52a0\u300d -> \u300c\u6587\u5b57\u5217\u300d\u3092\u9078\u629e\u3057\u3001\u300c\u540d\u524d\u300d\u306b\u30ad\u30fc\u3001\u300c\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u300d\u306b\u6e21\u3057\u305f\u3044\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

\"\"<\/p>\n

Ansible\u30b8\u30e7\u30d6\u306e\u8a2d\u5b9a<\/h2>\n

\u6b21\u306bAnsible\u5b9f\u884c\u6642\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u30bb\u30c3\u30c8\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n

Jenkins\u30c8\u30c3\u30d7 -> \u8a2d\u5b9a\u3057\u305f\u3044\u30b8\u30e7\u30d6\u3092\u9078\u629e -> \u8a2d\u5b9a -> invoke Ansible Playbook -> \u9ad8\u5ea6\u306a\u8a2d\u5b9a<\/code><\/p>\n

\"\"<\/p>\n

Additional parameters<\/code>\u306b\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002
\n--extra-vars '{"db_host":"${DB_HOST}"}'<\/code><\/p>\n

\u3053\u306e\u8a2d\u5b9a\u306f\u3001Jenkins\u306e\u30b0\u30ed\u30fc\u30d0\u30eb\u30d1\u30e9\u30e1\u30fc\u30bf\u3084\u30b8\u30e7\u30d6\u6bce\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u8a2d\u5b9a\u3057\u305fDB_HOST<\/code>\u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308a\u3001Ansible\u5074\u306edb_host<\/code>\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4e0a\u66f8\u3044\u3066Ansible\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n


\n

\u4ee5\u4e0a\u3001\u7c21\u5358\u3067\u3059\u304c\u300cJenkins\u304b\u3089Ansible\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u3066\u74b0\u5883\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u300d\u3067\u3057\u305f\u3002
\n\u5b8c\u5168\u306b\u500b\u4eba\u7684\u306a\u76ee\u7dda\u3067\u3059\u304c\u3001Jenkins\u306f\u8272\u3005\u30af\u30bb\u304c\u3042\u3063\u3066\u3001CircleCI\u306a\u3069\u306e\u3088\u3046\u306b\u306f\u76f4\u611f\u7684\u306b\u52d5\u304b\u305b\u306a\u3044\u3068\u3053\u308d\u304c\u3064\u3089\u3044\u3067\u3059\u304c\u3001\u81ea\u7531\u5ea6\u306f\u304b\u306a\u308a\u9ad8\u305d\u3046\u306a\u306e\u3067\u3001\u8272\u3005\u89e6\u3063\u3066\u307f\u308b\u3068\u9762\u767d\u3044\u304b\u3082\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u53c2\u8003 : How to pass parameter from Jenkins job to Ansible playbook<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

\u524d\u7530\u3067\u3059\u3002 \u6700\u8fd1\u306f\u7d99\u7d9a\u7684\u30a4\u30f3\u30c6\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30c4\u30fc\u30eb\u306bJenkins\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002 \u4eca\u307e\u3067\u305a\u3063\u3068CircleCI\u3092\u4f7f\u3063\u3066\u304d\u305f\u306e\u3067\u3001UI\u306a\u3069\u306b\u307e\u3060\u5168\u7136\u6163\u308c\u3066\u3044\u306a\u3044\u3067\u3059\u304c\u3001\u5c11\u3057\u305a\u3064\u899a\u3048\u3066\u3044\u3063\u3066\u3044\u307e\u3059\u3002 \u73fe\u5728\u6271\u3063\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3001Jenkins\u304b\u3089Ansible\u3092\u4f7f\u3063\u3066\u30b5\u30fc\u30d0\u306e\u74b0\u5883\u69cb\u7bc9\u3084\u30c7\u30d7\u30ed\u30a4\u3092\u3057\u3066\u3044\u307e\u3059\u3002 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3084Ansible\u306a\u3069\u306e\u69cb\u6210\u7ba1\u7406\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306fGitHub\u306a\u3069 […]<\/p>\n","protected":false},"author":1,"featured_media":826,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/382"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=382"}],"version-history":[{"count":0,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/382\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media\/826"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}