Commit eb7ce07d authored by nanahira's avatar nanahira

update

parent 4bcc62b5
......@@ -21,13 +21,19 @@
- name: 'frps'
include_tasks: 'protocols/wgfrp/frps.yaml'
when: 'frps_needed is defined'
- name: 鸟配置 (apt)
- name: 鸟配置 (Debian)
template:
src: bird.conf.j2
dest: '/etc/bird/bird.conf'
when: ansible_os_family == "Debian"
when: ansible_distribution == "Debian"
notify: restart_bird
- name: 鸟配置 (yum)
- name: 鸟配置 (Ubuntu)
template:
src: bird.conf.j2
dest: '/usr/local/etc/bird.conf'
when: ansible_distribution == "Debian"
notify: restart_bird
- name: 鸟配置 (RHEL)
template:
src: bird.conf.j2
dest: '/etc/bird.conf'
......
- hosts: wg
become: true
roles:
- frp
- bird
- wireguard
tasks:
- name: apt
apt:
update_cache: yes
name: bird2,tar,curl,wget
state: latest
when: 'ansible_os_family == "Debian"'
- name: yum
yum:
update_cache: yes
name: bird2,tar,curl,wget
state: latest
when: 'ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 8'
- name: dnf
dnf:
name: bird2,tar,curl,wget
state: latest
when: 'ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8'
- name: frp directory
file:
path: /tmp/frp
state: directory
- name: get frp
unarchive:
src: https://github.com/fatedier/frp/releases/download/v0.31.2/frp_0.31.2_linux_amd64.tar.gz
remote_src: true
creates:
- /tmp/frp/frpc
- /tmp/frp/frps
dest: /tmp/frp/
extra_opts:
- --strip-components=1
when: 'ansible_architecture == "x86_64"'
register: unarchive_result
- name: get frp for arm
unarchive:
src: https://github.com/fatedier/frp/releases/download/v0.31.2/frp_0.31.2_linux_arm64.tar.gz
remote_src: true
creates:
- /tmp/frp/frpc
- /tmp/frp/frps
dest: /tmp/frp/
extra_opts:
- --strip-components=1
when: 'ansible_architecture == "aarch64"'
register: unarchive_result
- name: install frp
shell: 'cp -rf /tmp/frp/frpc /usr/bin/ && cp -rf /tmp/frp/frps /usr/bin/ && cp -rf /tmp/frp/systemd/* /usr/lib/systemd/systemd/'
when: 'unarchive_result.changed'
- name: config directories
file:
path: '/etc/{{item}}'
state: directory
with_items:
- wireguard
- frp
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
---
# defaults file for bird
bird_version: 2.0.7
[Unit]
Description=BIRD Internet Routing Daemon
After=network.target
[Service]
ExecStartPre=/usr/local/sbin/bird -p
ExecReload=/usr/local/sbin/birdc configure
ExecStart=/usr/local/sbin/bird -f -u root -g root
Restart=on-abort
[Install]
WantedBy=multi-user.target
path: /usr/lib/systemd/system/bird.service
---
# handlers file for bird
\ No newline at end of file
galaxy_info:
author: Nanahira
description: install frp
company: MyCard
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# platforms is a list of platforms, and each platform has a name and a list of versions.
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
---
# tasks file for bird
- name: bird for Debian
apt:
update_cache: yes
name: bird2
state: latest
when: 'ansible_distribution == "Debian"'
- name: bird for RHEL 7
yum:
update_cache: yes
name: bird2
state: latest
when: 'ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 8'
- name: bird for RHEL 8
dnf:
name: bird2
state: latest
when: 'ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8'
- name: remove old bird
apt:
name: bird
state: absent
autoremove: yes
when: 'ansible_distribution == "Ubuntu"'
- name: detect bird
shell: which bird || true
when: 'ansible_distribution == "Ubuntu"'
register: bird_detection
- name: bird for Ubuntu
include_tasks: ubuntu.yaml
when: 'ansible_distribution == "Ubuntu" and bird_detection.stdout.length == 0'
- name: apt
apt:
update_cache: true
state: latest
name: tar,curl,wget,build-essential,flex,bison,libncurses5-dev,libreadline-dev
- name: get bird
unarchive:
src: 'https://minio.mycard.moe:9000/nanahira/bird-{{bird_version}}.tar.gz'
remote_src: true
creates: 'bird-{{bird_version}}'
dest: /tmp/
- name: configure
shell: ./configure
args:
chdir: '/tmp/bird-{{bird_version}}/'
- name: make
make:
chdir: '/tmp/bird-{{bird_version}}/'
params:
NUM_THREADS: '{{ansible_processor_vcpus}}'
- name: make install
make:
chdir: '/tmp/bird-{{bird_version}}/'
target: install
- name: systemd directory
file:
path: /usr/lib/systemd/system
state: directory
owner: root
group: root
mode: 0755
- name: systemd file
copy:
src: bird.service
dest: /usr/lib/systemd/system/bird.service
register: systemd_result
- name: daemon-reload
systemd:
daemon_reload: true
when: systemd_result.changed
---
- hosts: localhost
remote_user: root
roles:
- bird
\ No newline at end of file
---
# vars file for bird
\ No newline at end of file
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
---
# defaults file for frp
frp_version: 0.31.2
---
# handlers file for frp
\ No newline at end of file
galaxy_info:
author: Nanahira
description: install frp
company: MyCard
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# platforms is a list of platforms, and each platform has a name and a list of versions.
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
---
# tasks file for frp
- name: apt
apt:
name: tar,curl,wget
when: 'ansible_distribution == "Debian"'
- name: yum
yum:
name: tar,curl,wget
when: 'ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 8'
- name: dnf
dnf:
name: tar,curl,wget
when: 'ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8'
- name: frp directory
file:
path: /tmp/frp
state: directory
- name: get frp
unarchive:
src: https://minio.mycard.moe:9000/nanahira/frp_{{frp_version}}_linux_amd64.tar.gz
remote_src: true
creates: /tmp/frp/frpc
dest: /tmp/frp/
extra_opts:
- --strip-components=1
when: 'ansible_architecture == "x86_64"'
register: unarchive_result_1
- name: get frp for arm
unarchive:
src: https://minio.mycard.moe:9000/nanahira/frp_{{frp_version}}_linux_arm64.tar.gz
remote_src: true
creates: /tmp/frp/frpc
dest: /tmp/frp/
extra_opts:
- --strip-components=1
when: 'ansible_architecture == "aarch64"'
register: unarchive_result_2
- name: systemd directory
file:
path: /usr/lib/systemd/system
state: directory
owner: root
group: root
mode: 0755
- name: install frp
shell: 'cp -rf /tmp/frp/frpc /usr/bin/ && cp -rf /tmp/frp/frps /usr/bin/ && cp -rf /tmp/frp/systemd/* /usr/lib/systemd/system/'
when: 'unarchive_result_1.changed or unarchive_result_2.changed'
- name: daemon-reload
systemd:
daemon_reload: true
when: 'unarchive_result_1.changed or unarchive_result_2.changed'
- name: config directories
file:
path: '/etc/frp'
state: directory
---
- hosts: localhost
remote_user: root
roles:
- frp
\ No newline at end of file
---
# vars file for frp
\ No newline at end of file
......@@ -67,3 +67,7 @@
state: latest
name: wireguard-tools,wireguard-dkms
when: "ansible_distribution == 'CentOS' and ansible_distribution_major_version|int == 8"
- name: config directories
file:
path: '/etc/wireguard'
state: directory
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment