All Projects → lework → Ansible Roles

lework / Ansible Roles

Licence: mit
Ansible Roles

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Ansible Roles

Centos7 Cis
Ansible CentOS 7 - CIS Benchmark Hardening Script
Stars: ✭ 64 (-82.93%)
Mutual labels:  ansible, ansible-playbook, ansible-playbooks
Ansible Rails
Ansible: Ruby on Rails Server
Stars: ✭ 317 (-15.47%)
Mutual labels:  ansible, ansible-playbook, ansible-playbooks
Ansible Playbook Grapher
A command line tool to create a graph representing your Ansible playbook tasks and roles
Stars: ✭ 234 (-37.6%)
Mutual labels:  ansible, ansible-playbook
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+697.33%)
Mutual labels:  ansible, k8s
swiss-army
Ansible-driven configuration management for maintaining a preferred environment (base system and app dotfiles / configurations)
Stars: ✭ 44 (-88.27%)
Mutual labels:  ansible-playbook, ansible-playbooks
Spamscope
Fast Advanced Spam Analysis Tool
Stars: ✭ 223 (-40.53%)
Mutual labels:  ansible, ansible-playbook
Ansible Playbooks
Ansible Playbook for Icinga 2
Stars: ✭ 224 (-40.27%)
Mutual labels:  ansible, ansible-playbooks
ansible-palybooks
Ansible Palybooks Written and Published by www.server-computer.com. NO WARRANTY for any damages and loss of data.
Stars: ✭ 24 (-93.6%)
Mutual labels:  ansible-playbook, ansible-playbooks
Graylog Ansible Role
Ansible role which installs and configures Graylog
Stars: ✭ 173 (-53.87%)
Mutual labels:  ansible, ansible-playbook
lykops
lykops是一套web可视化的运维自动化项目,基于python3+django开发的。可视化、简化执行ansible任务,并提供详细的任务执行报告。
Stars: ✭ 129 (-65.6%)
Mutual labels:  ansible-playbook, ansible-playbooks
RHEL7-CIS
Ansible RHEL 7 - CIS Benchmark Hardening Script
Stars: ✭ 28 (-92.53%)
Mutual labels:  ansible-playbook, ansible-playbooks
kubeadm-ansible
Kuberadmin ansible is a toolkit for simple and quick installing k8s cluster.
Stars: ✭ 37 (-90.13%)
Mutual labels:  ansible-playbook, k8s
Shiva
An Ansible playbook to provision a host for penetration testing and CTF challenges
Stars: ✭ 220 (-41.33%)
Mutual labels:  ansible, ansible-playbook
Community.kubernetes
Kubernetes Collection for Ansible
Stars: ✭ 214 (-42.93%)
Mutual labels:  ansible, k8s
Rak8s
Stand up a Raspberry Pi based Kubernetes cluster with Ansible
Stars: ✭ 354 (-5.6%)
Mutual labels:  ansible, ansible-playbooks
Ansipress
AnsiPress - Simple L(Linux) E(NGINX) M(MariaDB) P(PHP7) Shared Hosting Setup
Stars: ✭ 184 (-50.93%)
Mutual labels:  ansible, mysql
Ansible Role Kubernetes
Ansible Role - Kubernetes
Stars: ✭ 247 (-34.13%)
Mutual labels:  ansible, k8s
K3s Ansible
Ansible playbook to deploy k3s kubernetes cluster
Stars: ✭ 153 (-59.2%)
Mutual labels:  ansible, k8s
Dellemc Openmanage Ansible Modules
Dell EMC OpenManage Ansible Modules
Stars: ✭ 169 (-54.93%)
Mutual labels:  ansible, ansible-playbook
useful-playbooks
🚚 Useful Ansible playbooks for easily deploy your website or webapp to absolutely fresh remote virtual server and automation many processes. Only 3 minutes from the playbook run to complete setup server and start it.
Stars: ✭ 52 (-86.13%)
Mutual labels:  ansible-playbook, ansible-playbooks

Ansible roles 怎么用? GitHub

系统环境

os: Centos 6.7 X64

python: 2.6.6

安装ansible和git

[install -y ansible git
[--version
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

设置ansible

关闭主机ssh known_hosts检查 配置文件:/etc/ansible/ansible.cfg

 59 host_key_checking = False

使用git 克隆ansible role

[[email protected] roles]# git clone https://github.com/lework/Ansible-roles.git /etc/ansible/roles/
Initialized empty Git repository in /etc/ansible/roles/.git/
remote: Counting objects: 165, done.
remote: Compressing objects: 100% (95/95), done.
remote: Total 165 (delta 37), reused 152 (delta 24), pack-reused 0
Receiving objects: 100% (165/165), 26.01 KiB | 19 KiB/s, done.
Resolving deltas: 100% (37/37), done.
[[email protected] roles]# ll /etc/ansible/roles/
总用量 36
drwxr-xr-x 5 root root 4096 3月  11 11:54 iptables
drwxr-xr-x 5 root root 4096 3月  11 11:54 java
drwxr-xr-x 4 root root 4096 3月  11 11:54 mvn
drwxr-xr-x 5 root root 4096 3月  11 11:54 nodejs
drwxr-xr-x 5 root root 4096 3月  11 11:54 os-init
drwxr-xr-x 5 root root 4096 3月  11 11:54 python2.7
drwxr-xr-x 4 root root 4096 3月  11 11:54 repo-epel
drwxr-xr-x 4 root root 4096 3月  11 11:54 ruby
drwxr-xr-x 5 root root 4096 3月  11 11:54 supervisor
[[email protected] roles]# 

添加主机清单

这里以192.168.77.130主机为例,并将其设为node2组内。

#/etc/ansible/hosts
[node2]
192.168.77.130 ansible_ssh_pass=123456

查看role的README.md文档

# Ansible Role: python2.7

Centos 6.7版本中的python2.6升级到2.7

## 要求

此角色仅在RHEL及其衍生产品上运行。

## 测试环境

ansible `2.2.1.0`
os `Centos 6.7 X64`

## 角色变量
	software_files_path: "/opt/software/"
	software_install_path: "/usr/local"

	python_version: "2.7.13"

	python_file: "Python-{{ python_version }}.tgz"
	python_file_path: "{{ software_files_path }}/{{ python_file }}"
	python_file_url: "http://www.python.org/ftp/python/{{ python_version }}/Python-{{ python_version }}.tgz"

	pip_source_url: "https://pypi.tuna.tsinghua.edu.cn/simple"
	change_pip_source: true


## 依赖

没有

## github地址
https://github.com/lework/Ansible-roles/tree/master/python2.7

## Example Playbook

    - hosts: servers
      roles:
        - python2.7
		
	- hosts: server
      roles:
        - { role: python2.7, python_version: "2.7.13"}
  • 上诉说明了此role在哪个环境下正常运行,其他环境暂不保证运行成功。
  • 可以自定义角色变量,达到自己想要的结果。比如想要安装python2.7.12的版本,可以在playbook中定义python_version: "2.7.12",就可以安装2.7.12版本的python了。
  • 如果文章中有依赖,必须先安装依赖,才能运行此role。
  • 在编写Playbook时也可以参考上列的Playbook例子。

编写playbook

这里以python2.7角色为例,将为node2组内的所有主机安装python2.7服务。 查看Ansible Role系统环境 之【python2.7】 使用帮助,根据自身情况设置相应的变量,这里设置python的版本为2.7.14。 文件路径:/etc/ansible/roles/python2.7.yml

---

- hosts: node2
  
  roles:
    - { role: python2.7, python_version: "2.7.14"}

执行playbook

[[email protected] ansible]# ansible-playbook python2.7.yml 

PLAY [node2] *******************************************************************

TASK [setup] *******************************************************************
ok: [192.168.77.130]

TASK [python2.7 : Copy python file to agent.] **********************************
ok: [192.168.77.130]

TASK [python2.7 : Create software files .] *************************************
ok: [192.168.77.130]

TASK [python2.7 : Download python file.] ***************************************
changed: [192.168.77.130]

TASK [python2.7 : Check if python remote soft link is already configured.] *****
ok: [192.168.77.130]

TASK [python2.7 : Check if python remote soft old link is already configured.] *
ok: [192.168.77.130]

TASK [python2.7 : Ensure packages are installed.] ******************************
ok: [192.168.77.130] => (item=[u'zlib', u'zlib-devel', u'openssl', u'openssl-devel', u'python-devel', u'gcc'])

TASK [python2.7 : Copy python file to agent.] **********************************
changed: [192.168.77.130]

TASK [python2.7 : Build python.] ***********************************************
changed: [192.168.77.130]

TASK [python2.7 : Move python old version and Create python dir soft link.] ****
changed: [192.168.77.130]

TASK [python2.7 : Replace file python env path.] *******************************
changed: [192.168.77.130] => (item=/usr/sbin/iotop)
changed: [192.168.77.130] => (item=/usr/bin/yum)

TASK [python2.7 : Check if pip is already configured.] *************************
ok: [192.168.77.130]

TASK [python2.7 : Install python2.7 pip.] **************************************
changed: [192.168.77.130]
 [WARNING]: Consider using get_url or uri module rather than running curl


TASK [python2.7 : Create pip config dir.] **************************************
changed: [192.168.77.130]

TASK [python2.7 : Change pip source.] ******************************************
changed: [192.168.77.130]

PLAY RECAP *********************************************************************
192.168.77.130             : ok=15   changed=8    unreachable=0    failed=0 

查看主机是否安装了python2.7版本

使用ad-hoc方式查看

[-m shell -a 'python -V'
192.168.77.130 | SUCCESS | rc=0 >>
Python 2.7.12

在主机上查看

[-V
Python 2.7.12

至此,ansible role怎么使用大家都明白了把。如果有疑问的话,欢迎大家来QQ群【425931784 已满员】【756527917】交流