如何使用ansible在特定主机上安装依赖角色

时间:2016-01-27 13:45:09

标签: ansible

我有以下0dp脚本:

width

我需要在特定主机上安装role/meta/main.yml角色,比如说--- dependencies: - role: common - role: nginx - role: postgres - role: my_db

2 个答案:

答案 0 :(得分:0)

如果您只想安装一个卷,则应创建一个仅将该角色应用于主机的剧本。

<html>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "zz224466";
$database = "zain";
$conn = mysqli_connect($servername,$username,$password,$database);
if($conn->connect_error) {
    die("connection failed: " . $conn->connect_error);
}

if(isset($_GET['edit'])) {
    $id = $_GET["edit"];  
    echo $id; 
    $res = mysqli_query($conn, "SELECT * FROM product where product_id=$id");
    if ($res == FALSE) {
        die("Error");

    }
    $row = mysqli_fetch_array($res);
    if (isset($_POST['Edit'])) {  
        $product_category = $_POST['product_category'];
        $product_id = $_GET['edit']; // Change Here

        // Changes here 
        $sql_category = "UPDATE product SET product_category='$product_category' WHERE product_id=$product_id";
        if (mysqli_query($conn, $sql_category)) {

        }
    }
}?>
    // Changes here in form tag 
    <form method="post" action ="edit.php?edit=<?echo $_GET['edit'];?>" id="contact-form"> 
          <input type="text" name="product_category" placeholder="product_category" value="<?php if(isset($row['product_category'])) { echo $row['product_category']; }?>"/>
          <div class="btn-group" role="group">
              <input type="submit" class="btn btn-default" name="Edit" value="Save Edits" style="margin-top: 15px; margin-right: 15px; border-radius: 4px;">
          </div>
    </form>
</body>
</html>

答案 1 :(得分:0)

解决方案是:

---
dependencies:
-hosts: 4.3.2.1
  roles:common nginx postgres

-hosts: 1.2.3.4
  roles:my_db

并专门在my_db主机上安装1.2.3.4个角色。