Tumgik
sysnotes · 5 years
Text
Messy Notes on CoreOS MatchBox
CoreOS Matchbox Setup Notes.
dnsmasq
interface=eth1 bind-interfaces dhcp-range=10.16.0.10,10.16.0.99,255.255.255.0,24h dhcp-option=option:router,10.16.0.1 dhcp-boot=pxelinux.0 enable-tftp tftp-root=/srv/tftp dhcp-match=gpxe,175 # gPXE sends a 175 option. dhcp-boot=net:#gpxe,undionly.kpxe dhcp-boot=http://10.16.0.1/boot.ipxe address=/node1/10.16.0.101 address=/node2/10.16.0.102 address=/node3/10.16.0.103
profiles json:
{ "id": "bootkube", "name": "bootkube", "cloud_id": "", "ignition_id": "bootkube.yml", "generic_id": "", "boot": { "kernel": "/assets/vmlinuz", "initrd": ["/assets/cpio.gz"], "args": [ "root=/dev/vda1", "coreos.config.url=http://10.16.0.1/ignition?uuid=${uuid}&mac=${mac:hexhyp}", "coreos.first_boot=yes", "coreos.autologin" ] } }
groups json:
{ "name": "bootkube1", "profile": "bootkube", "selector": { "mac": "52:54:00:90:c3:6e" }, "metadata": { "domain_name": "node1", "ADVERTISE_IP": "10.16.0.101", "SERVER_IP": "10.16.0.1", "etcd_initial_cluster": "node1=http://10.16.0.101:2380,node2=http://10.16.0.102:2380,node3=http://10.16.0.103:2380", "etcd_name": "node1", "k8s_dns_service_ip": "10.3.0.10" } }
ignitons yml:
passwd: users: - name: core ssh_authorized_keys: - ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFTHetURpsQ2fkYXhAGMPDPArd4ubKfwRFvtcXtcp/PAnO8LFg4xQCtUbpgj4KoLYZEXblz/woXlm4coXT3C9Sg= networkd: units: - name: 005-eth0.network contents: | [Match] Name=eth0 [Network] DNS={{.SERVER_IP}} Address={{.ADVERTISE_IP}}/24 Gateway={{.SERVER_IP}} etcd: version: 3.3.9 name: {{.etcd_name}} advertise_client_urls: http://{{.ADVERTISE_IP}}:2379 initial_advertise_peer_urls: http://{{.ADVERTISE_IP}}:2380 listen_client_urls: http://0.0.0.0:2379 listen_peer_urls: http://0.0.0.0:2380 initial_cluster: {{.etcd_initial_cluster}} #ca_file: /etc/ssl/certs/etcd/etcd/server-ca.crt #cert_file: /etc/ssl/certs/etcd/etcd/server.crt #key_file: /etc/ssl/certs/etcd/etcd/server.key #peer_ca_file: /etc/ssl/certs/etcd/etcd/peer-ca.crt #peer_cert_file: /etc/ssl/certs/etcd/etcd/peer.crt #peer_key_file: /etc/ssl/certs/etcd/etcd/peer.key systemd: units: - name: update-engine.service mask: true - name: locksmithd.service mask: true - name: etcd-member.service enable: true - name: docker.service enable: true - name: rngd.service enable: true contents: | [Unit] Description=Hardware RNG Entropy Gatherer Daemon [Service] ExecStart=/usr/sbin/rngd -f -r /dev/urandom [Install] WantedBy=multi-user.target - name: get-assets.service enable: true contents: | [Unit] Description=Get Bootkube assets [Service] Type=oneshot ExecStart=/usr/bin/wget --cut-dirs=1 -R "index.html*" --recursive -nH http://{{.SERVER_IP}}/assets -P /opt/bootkube/assets #ExecStartPre=/usr/bin/wget --cut-dirs=2 -R "index.html*" --recursive -nH http://10.16.0.1/assets/tls -P /etc/ssl/certs/etcd #ExecStartPre=/usr/bin/chown etcd:etcd -R /etc/ssl/etcd #ExecStartPre=/usr/bin/find /etc/ssl/etcd -type f -exec chmod 600 {} \; [Install] WantedBy=multi-user.target - name: kubelet.service enable: true contents: | [Unit] Description=Kubelet via Hyperkube ACI [Service] EnvironmentFile=/etc/kubernetes/kubelet.env Environment="RKT_RUN_ARGS=--uuid-file-save=/var/cache/kubelet-pod.uuid \ --volume=resolv,kind=host,source=/etc/resolv.conf \ --mount volume=resolv,target=/etc/resolv.conf \ --volume var-lib-cni,kind=host,source=/var/lib/cni \ --mount volume=var-lib-cni,target=/var/lib/cni \ --volume opt-cni-bin,kind=host,source=/opt/cni/bin \ --mount volume=opt-cni-bin,target=/opt/cni/bin \ --volume var-log,kind=host,source=/var/log \ --mount volume=var-log,target=/var/log \ --insecure-options=image" ExecStartPre=/bin/mkdir -p /opt/cni/bin ExecStartPre=/bin/mkdir -p /etc/kubernetes/manifests ExecStartPre=/bin/mkdir -p /etc/kubernetes/cni/net.d ExecStartPre=/bin/mkdir -p /etc/kubernetes/checkpoint-secrets ExecStartPre=/bin/mkdir -p /etc/kubernetes/inactive-manifests ExecStartPre=/bin/mkdir -p /var/lib/cni ExecStartPre=/usr/bin/bash -c "grep 'certificate-authority-data' /etc/kubernetes/kubeconfig | awk '{print $2}' | base64 -d > /etc/kubernetes/ca.crt" ExecStartPre=-/usr/bin/rkt rm --uuid-file=/var/cache/kubelet-pod.uuid ExecStart=/usr/lib/coreos/kubelet-wrapper \ --anonymous-auth=false \ --cluster-dns={{.k8s_dns_service_ip}} \ --cluster-domain=cluster.local \ --client-ca-file=/etc/kubernetes/ca.crt \ --pod-manifest-path=/etc/kubernetes/manifests \ --feature-gates=AttachVolumeLimit=false \ --cni-conf-dir=/etc/kubernetes/cni/net.d \ --exit-on-lock-contention \ --kubeconfig=/etc/kubernetes/kubeconfig \ --lock-file=/var/run/lock/kubelet.lock \ --network-plugin=cni \ --node-labels=node-role.kubernetes.io/master \ --register-with-taints=node-role.kubernetes.io/master=:NoSchedule ExecStop=-/usr/bin/rkt stop --uuid-file=/var/cache/kubelet-pod.uuid Restart=always RestartSec=10 [Install] WantedBy=multi-user.target - name: bootkube.service #enable: true contents: | [Unit] Description=Bootstrap a Kubernetes control plane with a temp api-server [Service] Type=simple WorkingDirectory=/opt/bootkube ExecStart=/opt/bootkube/bootkube-start [Install] WantedBy=multi-user.target storage: disks: - device: /dev/vda wipe_table: true partitions: - label: ROOT filesystems: - name: root mount: device: "/dev/vda1" format: "ext4" create: force: true options: - "-LROOT" files: - path: /etc/kubernetes/kubeconfig filesystem: root mode: 0644 contents: remote: url: http://{{.SERVER_IP}}/assets/auth/kubeconfig - path: /etc/kubernetes/kubelet.env filesystem: root mode: 0644 contents: inline: | KUBELET_IMAGE_URL=docker://gcr.io/google_containers/hyperkube KUBELET_IMAGE_TAG=v1.12.1 - path: /etc/hostname filesystem: root mode: 0644 contents: inline: {{.domain_name}} - path: /etc/sysctl.d/max-user-watches.conf filesystem: root contents: inline: | fs.inotify.max_user_watches=16184 - path: /opt/bootkube/bootkube-start filesystem: root mode: 0544 contents: inline: | #!/bin/bash set -e BOOTKUBE_ACI="${BOOTKUBE_ACI:-quay.io/coreos/bootkube}" BOOTKUBE_VERSION="${BOOTKUBE_VERSION:-v0.14.0}" #BOOTKUBE_VERSION="${BOOTKUBE_VERSION:-v0.9.1}" BOOTKUBE_ASSETS="${BOOTKUBE_ASSETS:-/opt/bootkube/assets}" exec /usr/bin/rkt run \ --trust-keys-from-https \ --volume assets,kind=host,source=$BOOTKUBE_ASSETS \ --mount volume=assets,target=/assets \ --volume bootstrap,kind=host,source=/etc/kubernetes \ --mount volume=bootstrap,target=/etc/kubernetes \ $RKT_OPTS \ ${BOOTKUBE_ACI}:${BOOTKUBE_VERSION} \ --net=host \ --dns=host \ --exec=/bootkube -- start --asset-dir=/assets "$@"
bootkube render --asset-dir=bootkube-assets --api-servers=https://10.16.0.101:6443,https://10.16.0.102:6443,https://10.16.0.103:6443 --api-server-alt-names=IP=10.16.0.101,IP=10.16.0.102,IP=10.16.0.103 --etcd-servers=http://10.16.0.101:2379,http://10.16.0.102:2379,http://10.16.0.103:2379 --network-provider experimental-canal
0 notes
sysnotes · 6 years
Text
VIMRC
set nocompatible set backspace=indent,eol,start set history=10000 set ruler set showcmd set wildmenu set ttimeout set ttimeoutlen=100 set scrolloff=5 set incsearch set nrformats-=octal map Q gq inoremap u syntax on filetype plugin indent on set re=1 set iminsert=0 set imsearch=0 set bs=2 set nowrapscan set number set list set hlsearch set cursorline set tabstop=4 set shiftwidth=4 set expandtab set clipboard=unnamed set mouse+=a "set listchars+=space:␣,eol:⏎ set listchars+=eol:⏎ try colorscheme badwolf catch /^Vim\%((\a\+)\)\=:E185/ colorscheme desert endtry if &diff try colorscheme jellybeans catch /^Vim\%((\a\+)\)\=:E185/ colorscheme desert endtry endif
0 notes
sysnotes · 6 years
Text
ZSHRC
##### Keybinds ##### if [[ ${TERM} == 'dumb' ]]; then return 1 fi zmodload -F zsh/terminfo +b:echoti +p:terminfo typeset -gA key_info key_info=( 'Control' '\C-' 'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd \eOD' 'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc \eOC' 'Escape' '\e' 'Meta' '\M-' 'Backspace' ${terminfo[kbs]} 'BackTab' ${terminfo[kcbt]} 'Left' ${terminfo[kcub1]} 'Down' ${terminfo[kcud1]} 'Right' ${terminfo[kcuf1]} 'Up' ${terminfo[kcuu1]} 'Delete' ${terminfo[kdch1]} 'End' ${terminfo[kend]} 'F1' ${terminfo[kf1]} 'F2' ${terminfo[kf2]} 'F3' ${terminfo[kf3]} 'F4' ${terminfo[kf4]} 'F5' ${terminfo[kf5]} 'F6' ${terminfo[kf6]} 'F7' ${terminfo[kf7]} 'F8' ${terminfo[kf8]} 'F9' ${terminfo[kf9]} 'F10' ${terminfo[kf10]} 'F11' ${terminfo[kf11]} 'F12' ${terminfo[kf12]} 'Home' ${terminfo[khome]} 'Insert' ${terminfo[kich1]} 'PageDown' ${terminfo[knp]} 'PageUp' ${terminfo[kpp]} ) local key for key (${(s: :)key_info[ControlLeft]}) bindkey ${key} backward-word for key (${(s: :)key_info[ControlRight]}) bindkey ${key} forward-word [[ -n ${key_info[Home]} ]] && bindkey ${key_info[Home]} beginning-of-line [[ -n ${key_info[End]} ]] && bindkey ${key_info[End]} end-of-line [[ -n ${key_info[PageUp]} ]] && bindkey ${key_info[PageUp]} up-line-or-history [[ -n ${key_info[PageDown]} ]] && bindkey ${key_info[PageDown]} down-line-or-history [[ -n ${key_info[Insert]} ]] && bindkey ${key_info[Insert]} overwrite-mode if [[ ${zdouble_dot_expand} == 'true' ]]; then double-dot-expand() { if [[ ${LBUFFER} == *.. ]]; then LBUFFER+='/..' else LBUFFER+='.' fi } zle -N double-dot-expand bindkey '.' double-dot-expand fi [[ -n ${key_info[Backspace]} ]] && bindkey ${key_info[Backspace]} backward-delete-char [[ -n ${key_info[Delete]} ]] && bindkey ${key_info[Delete]} delete-char [[ -n ${key_info[Left]} ]] && bindkey ${key_info[Left]} backward-char [[ -n ${key_info[Right]} ]] && bindkey ${key_info[Right]} forward-char bindkey ' ' magic-space bindkey "${key_info[Control]}L" clear-screen [[ -n ${key_info[BackTab]} ]] && bindkey ${key_info[BackTab]} reverse-menu-complete autoload -Uz is-at-least && if ! is-at-least 5.3; then expand-or-complete-with-redisplay() { print -Pn '...' zle expand-or-complete zle redisplay } zle -N expand-or-complete-with-redisplay bindkey "${key_info[Control]}I" expand-or-complete-with-redisplay fi zle-line-init() { (( ${+terminfo[smkx]} )) && echoti smkx } zle-line-finish() { (( ${+terminfo[rmkx]} )) && echoti rmkx } zle -N zle-line-init zle -N zle-line-finish ##### History search ##### typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE='' typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY='' typeset -g BUFFER MATCH MBEGIN MEND CURSOR typeset -g _history_substring_search_refresh_display typeset -g _history_substring_search_query_highlight typeset -g _history_substring_search_result typeset -g _history_substring_search_query typeset -g -a _history_substring_search_query_parts typeset -g -a _history_substring_search_raw_matches typeset -g -i _history_substring_search_raw_match_index typeset -g -a _history_substring_search_matches typeset -g -i _history_substring_search_match_index typeset -g -A _history_substring_search_unique_filter history-substring-search-up() { _history-substring-search-begin _history-substring-search-up-history || _history-substring-search-up-buffer || _history-substring-search-up-search _history-substring-search-end } history-substring-search-down() { _history-substring-search-begin _history-substring-search-down-history || _history-substring-search-down-buffer || _history-substring-search-down-search _history-substring-search-end } zle -N history-substring-search-up zle -N history-substring-search-down zmodload -F zsh/parameter if [[ $+functions[_zsh_highlight] -eq 0 ]]; then _zsh_highlight() { if [[ $KEYS == [[:print:]] ]]; then region_highlight=() fi } _zsh_highlight_bind_widgets() { zmodload zsh/zleparameter 2>/dev/null || { echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2 return 1 } local cur_widget for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep|yank*)}; do case $widgets[$cur_widget] in user:$cur_widget|user:_zsh_highlight_widget_*);; user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \ _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \ _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; builtin) eval "_zsh_highlight_widget_$cur_widget() { builtin zle .$cur_widget -- \"\$@\" && _zsh_highlight }; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; esac done } _zsh_highlight_bind_widgets fi _history-substring-search-begin() { setopt localoptions extendedglob _history_substring_search_refresh_display= _history_substring_search_query_highlight= if [[ -n $BUFFER && $BUFFER == ${_history_substring_search_result:-} ]]; then return; fi _history_substring_search_result='' if [[ -z $BUFFER ]]; then _history_substring_search_query= _history_substring_search_query_parts=() _history_substring_search_raw_matches=() else _history_substring_search_query=$BUFFER if [[ -n $HISTORY_SUBSTRING_SEARCH_FUZZY ]]; then _history_substring_search_query_parts=(${=_history_substring_search_query}) else _history_substring_search_query_parts=(${_history_substring_search_query}) fi local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#~^]/\\$MATCH}*" _history_substring_search_raw_matches=(${(k)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${search_pattern}]}) fi _history_substring_search_raw_match_index=0 _history_substring_search_matches=() _history_substring_search_unique_filter=() if [[ $WIDGET == history-substring-search-down ]]; then _history_substring_search_match_index=1 else _history_substring_search_match_index=0 fi } _history-substring-search-end() { setopt localoptions extendedglob _history_substring_search_result=$BUFFER if [[ $_history_substring_search_refresh_display -eq 1 ]]; then region_highlight=() CURSOR=${#BUFFER} fi _zsh_highlight if [[ -n $_history_substring_search_query_highlight ]]; then local highlight_start_index=0 local highlight_end_index=0 for query_part in $_history_substring_search_query_parts; do local escaped_query_part=${query_part//(#m)[\][()|\\*?#~^]/\\$MATCH} local query_part_match_index=${${BUFFER:$highlight_start_index}[(i)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)${escaped_query_part}]} if [[ $query_part_match_index -le ${#BUFFER:$highlight_start_index} ]]; then highlight_start_index=$(( $highlight_start_index + $query_part_match_index )) highlight_end_index=$(( $highlight_start_index + ${#query_part} )) region_highlight+=("$(($highlight_start_index - 1)) $(($highlight_end_index - 1)) $_history_substring_search_query_highlight") fi done fi return 0 } _history-substring-search-up-buffer() { local buflines XLBUFFER xlbuflines buflines=(${(f)BUFFER}) XLBUFFER=$LBUFFER"x" xlbuflines=(${(f)XLBUFFER}) if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xlbuflines -ne 1 ]]; then zle up-line-or-history return 0 fi return 1 } _history-substring-search-down-buffer() { local buflines XRBUFFER xrbuflines buflines=(${(f)BUFFER}) XRBUFFER="x"$RBUFFER xrbuflines=(${(f)XRBUFFER}) if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xrbuflines -ne 1 ]]; then zle down-line-or-history return 0 fi return 1 } _history-substring-search-up-history() { if [[ -z $_history_substring_search_query ]]; then if [[ $HISTNO -eq 1 ]]; then BUFFER= else zle up-line-or-history fi return 0 fi return 1 } _history-substring-search-down-history() { if [[ -z $_history_substring_search_query ]]; then if [[ $HISTNO -eq 1 && -z $BUFFER ]]; then BUFFER=${history[1]} _history_substring_search_refresh_display=1 else zle down-line-or-history fi return 0 fi return 1 } _history_substring_search_process_raw_matches() { while [[ $_history_substring_search_raw_match_index -lt $#_history_substring_search_raw_matches ]]; do _history_substring_search_raw_match_index+=1 local index=${_history_substring_search_raw_matches[$_history_substring_search_raw_match_index]} if [[ ! -o HIST_IGNORE_ALL_DUPS && -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then local entry=${history[$index]} if [[ -z ${_history_substring_search_unique_filter[$entry]} ]]; then _history_substring_search_unique_filter[$entry]=1 _history_substring_search_matches+=($index) return 0 fi else _history_substring_search_matches+=($index) return 0 fi done return 1 } _history-substring-search-has-next() { if [[ $_history_substring_search_match_index -lt $#_history_substring_search_matches ]]; then return 0 else _history_substring_search_process_raw_matches return $? fi } _history-substring-search-has-prev() { if [[ $_history_substring_search_match_index -gt 1 ]]; then return 0 else return 1 fi } _history-substring-search-found() { BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND } _history-substring-search-not-found() { BUFFER=$_history_substring_search_query _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND } _history-substring-search-up-search() { _history_substring_search_refresh_display=1 if [[ $_history_substring_search_match_index -gt $#_history_substring_search_matches ]]; then _history-substring-search-not-found return fi if _history-substring-search-has-next; then _history_substring_search_match_index+=1 _history-substring-search-found else _history_substring_search_match_index+=1 _history-substring-search-not-found fi if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then return fi if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then _history-substring-search-up-search fi } _history-substring-search-down-search() { _history_substring_search_refresh_display=1 if [[ $_history_substring_search_match_index -lt 1 ]]; then _history-substring-search-not-found return fi if _history-substring-search-has-prev; then _history_substring_search_match_index+=-1 _history-substring-search-found else _history_substring_search_match_index+=-1 _history-substring-search-not-found fi if [[ -o HIST_IGNORE_ALL_DUPS || -n $HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE ]]; then return fi if [[ -o HIST_FIND_NO_DUPS && $BUFFER == $_history_substring_search_result ]]; then _history-substring-search-down-search fi } zmodload -F zsh/terminfo +p:terminfo bindkey "${terminfo[kcuu1]}" history-substring-search-up bindkey "${terminfo[kcud1]}" history-substring-search-down ##### History options ##### HISTFILE="${ZDOTDIR:-${HOME}}/.zsh_history" HISTSIZE=10000 SAVEHIST=10000 setopt BANG_HIST setopt EXTENDED_HISTORY setopt INC_APPEND_HISTORY setopt SHARE_HISTORY setopt HIST_IGNORE_DUPS setopt HIST_IGNORE_ALL_DUPS setopt HIST_IGNORE_SPACE setopt HIST_SAVE_NO_DUPS setopt HIST_VERIFY ##### Directory ##### setopt AUTO_CD setopt AUTO_PUSHD setopt PUSHD_IGNORE_DUPS setopt PUSHD_SILENT setopt PUSHD_TO_HOME setopt EXTENDED_GLOB setopt MULTIOS setopt NO_CLOBBER ##### Custom ##### autoload -Uz vcs_info zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' formats ' (%b) ' precmd() { vcs_info } PROMPT='[%n@%m %(3~|..%2~|%~)]%F{blue}${vcs_info_msg_0_}%f%(!.#.$) ' setopt correct setopt prompt_subst zstyle ':completion:*' rehash true zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' bindkey '^R' history-incremental-search-backward autoload -Uz compinit compinit
0 notes
sysnotes · 6 years
Text
Ansible Cheat Sheet
Quick setup notes for ansible.
1. Installation and root directory setup.
mkdir ansible cd ansible python3 -m venv venv source venv/bin/activate pip install ansible touch localhost production staging ansible.cfg site.yml mkdir -p group_vars host_vars library module_utils filter_plugins roles/common/{tasks,handlers,templates,vars,defaults,meta,library,module_utils,lookup_plugins} echo 'venv\nsite.retry' > .gitignore
2. Write what to import in site.yml
e.g. - import_playbook: nginx.yml
3. Write what role to include in yml imported in site.yml
e.g. - hosts: nginx roles: - common - nginx
4. Make sure that the hosts specified exist in host file(production, staging files).
e.g.(production): [nginx] live.nginx.nl:9432 e.g.(staging): [nginx] staging.nginx.nl e.g.(localhost): [nginx] hostname.local
5. Create roles specified in the individual yml.
# Create base directories mkdir -p roles/nginx/{defaults,handlers,library,lookup_plugins,meta,module_utils,tasks,templates,vars} # Create a task yml vim roles/common/tasks/main.yml
- name: ensure python3 pacman: name: python state: installed tag: python become: yes
touch roles/nginx/templates/nginx.conf.j2 vim roles/nginx/tasks/main.yml
- name: ensure nginx installation pacman: name: nginx state: installed tag: nginx become: yes - name: ensure nginx service service: name: nginx state: started become: yes - name: ensure main nginx config file template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf notify: - reload nginx tags: nginx become: yes
# Add handlers specified in notify vim roles/nginx/handlers/main.yml
- name: reload nginx service: name=nginx state=reloaded become: true
6. Run. Make sure the ansible host has ssh access to servers with root access
# Apply only staging hosts ansible-playbook -i staging site.yml # Apply only production hosts ansible-playbook -i production site.yml # Apply from clients. ansible-pull -U ssh://192.168.100.10/git/ansible -i localhost site.yml
0 notes