2015-02-08 55 views
2

我有一個bash腳本建立一個擦.deb軟件包中,我想使用的服務器架構服務器架構...bash腳本,如何從ansible設置

我安裝ansible和運行ansible本地主機 - M設置,這給了我ansible事實...

> ansible localhost -m setup 
localhost | success >> { 
"ansible_facts": { 
    "ansible_all_ipv4_addresses": [ 
     "10.10.5.200" 
    ], 
    "ansible_all_ipv6_addresses": [ 
     "fe80::4c2:ccff:fe82:8d8c" 
    ], 
    "ansible_architecture": "x86_64", 
    "ansible_bios_date": "06/02/2014", 

..

我想用檢測架構 「ansible_architecture」:在我的shell腳本我FPM命令中的 「x86_64的」:

currently : 
    fpm -s dir -t deb -n ruby$version -v $rubyversion -C $destdir \ 
    -p ruby-VERSION_ARCH~trusty.deb -d "libstdc++6 (>= 4.4.3)" \ 
    -d "libc6 (>= 2.6)" -d "libffi6 (>= 3.0.10)" -d "libgdbm3 (>= 1.8.3)" \ 
    -d "libncurses5 (>= 5.7)" -d "libreadline6 (>= 6.1)" \ 
    -d "libssl1.0.0 (>= 1.0.1)" -d "zlib1g (>= 1:1.2.2)" \ 
    -d "libyaml-0-2 (>= 0.1.4-2)" \ 
    usr/local/bin usr/local/lib usr/local/share/man usr/local/include 

    # VERSION_ARCH is giving me 'amd64' and I would like to use 
    # ansible_architecture (which is detecting "x86_64".... 

我可能沒有使用ansible事實來檢測它...

#我想在我的劇本 $架構開始寫= uname -m #,但它確實給了我「x86_64的」如一個變量...

感謝您的建議

回答

1

得到它: 插入

architecture="$(uname -m)" 
echo "architecture: $architecture" 

在我的腳本的開始,並使用$架構作爲參數