2016-04-14 42 views
3

我已經創建了一個小型的學習aws基礎設施來學習SaltStack。有三個ec2實例已經運行。 (主人和兩個僕從)。其中一名僕從沒有任何作用,一名僕從的角色可以讓他進入ec2和s3的行動。 (角色設置純粹是出於測試目的。)配置salt-master/salt-minion的aws服務的訪問

我試圖去發現是如何配置鹽主(或鹽僕從?)所以它可以訪問AWS服務。現在,我可以通過SSH訪問第二個小工具,並使用boto3進入ec2和ss3。但是如果我使用salt-master => salt-minion中的boto_ec2執行模塊,會發生訪問錯誤。我知道有/etc/salt/cloud.providers/etc/salt/cloud.profiles應該使用的配置。我看到的大部分例子都期望salt-minions將由salt創建,所以我有點困惑如何用已有的實例來做到這一點。

所以問題是:「什麼是正確和正確的方式來配置master和minions,以便能夠使用bash_ec2模塊(或任何其他)從salt-master和orchestrate minions。在哪裏以及如何AWS憑證(密鑰)被設置?必須修改/添加哪些配置文件,必須運行哪些命令?實例已經啓動。「

我發現這個鏈接:https://salt-cloud.readthedocs.org/en/latest/topics/aws.html但也有一些地方,在那裏說:

"The following settings are always required for EC2:" 

# Set the EC2 login data 
my-ec2-config: 
    id: HJGRYCILJLKJYG 
    key: 'kdjgfsgm;woormgl/aserigjksjdhasdfgn' 
    keyname: test 
    securitygroup: quick-start 
    private_key: /root/test.pem 
    provider: ec2 

但它不是說這個地方應該配置是。在主/奴才?哪個檔案? 當我運行命令:

# salt '*142*' boto_ec2.exists Master 
: 'boto_ec2' __virtual__ returned False 
ERROR: Minions returned with non-zero exit code 

它不工作。

+0

潛在投票下降主題。 – mootmoot

+0

你是什麼意思? – Divisadero

+0

描述你面臨的實際問題以及迄今爲止所做的工作。這個問題聽起來像是開放式的。 – mootmoot

回答

2

請記住,雲支持並未緊密集成在鹽堆中。

如何使用預先存在的實例執行此操作。 假設您有3個EC2實例。 S1(鹽大師),M1 & M2是你想要部署食鹽的地方。

方法1:安裝你的鹽主內鹽雲,使用saltify方法

# filename : /etc/cloud.providers.d/sality-driver.conf 
aws-saltify: 
    minion: 
    master: <ip_address_of_your_salt_master> 
    driver: saltify  

# filename : /etc/cloud.profiles.d/salt-minion.conf 
minion1: 
    ssh_host: <M1-ip> 
    ssh_username: <your_aws_instance_user_name> 
    key_filename: "<full private_key_file path use to connect to minion>" 
    provider: aws-saltify 

minion2: 
    ssh_host: <M2-ip> 
    ssh_username: <your_aws_instance_user_name> 
    key_filename: "<full private_key_file path use to connect to minion2>" 
    provider: aws-saltify 

# run the command to saltify those host 

sudo salt-cloud saltify -p minion1 <minion1-host-name> 
sudo salt-cloud saltify -p minion2 <minion2-host-name> 

手指交叉,如果它的工作原理。

**方法2:使用鹽-SSH **

重要提示:salt.state.boto_ec2是不是2015年8月8日在完成(2016年3月)。所以你真的不能使用boto_ec2將salt-minion部署到這些機器上,也許你可能會嘗試boto_lc或等待新功能。

#Create a folder just for salt-ssh deployment 
mkdir ~/saltme 

# master file for salt-ssh ~/saltme/master 
file_roots: 
    base: 
    # Replace the "~" with you $HOME full path. 
    - ~/saltme/master 

#create a roster file ~/saltme/minion-roster 
my-bare-M1: 
    host: <to-be-minion-1-host-ip-address> 
    user: <ami-default > 
    sudo: True 

my-bare-M2: 
    host: <to-be-minion-2-host-ip-address> 
    user: <ami-default > 
    sudo: True 

# create your top file ~/saltme/top.sls 
base: 
    '*': 
    - saltify-minion 

# create the state file ~/saltme/saltify-minion.sls 
salt-minion: 
    pkg.installed 


# Now , inside the ~/saltme , run this against each to-be-minion-ec2 
salt-ssh --roster-file roster --config-dir $HOME/saltme -i --priv saltminion-1.pem 'my-bare-M1' state.highsatte 

salt-ssh --roster-file roster --config-dir $HOME/saltme -i --priv saltminion-1.pem 'my-bare-M2' state.highsatte 
#Now accept the salt-minion key 
sudo salt-key -A 
+0

有方法3.將salt-minion添加到salt-master中,然後使用boto_lc.present,但我不確定狀態如何識別現有的EC2實例。我知道salt-cloud使用Tag名稱來標識實例,但對boto_lc沒有任何線索。 – mootmoot

相關問題